I updated my rules and can get every redirect to work except for https://www.freertool.com/store/en links
for example https://www.freertool.com/store/en/freer-naams-alb081 wont work but if i remove the S on HTTPS it goes through. I am just missing a step i believe should i create another rule to handle Https prior to loading the other rules?
<rules>
<clear />
<rule name="Store Redirect Store www" stopProcessing="true">
<match url="^www.freertool.com/store(.*)" />
negate="true" />
<action type="Redirect" url="http://freertool.com{R:1}" />
</rule>
<rule name="Store Redirect EN" enabled="true" stopProcessing="true">
<match url="^en(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http://freertool.com{R:1}" />
</rule>
<rule name="Store Redirect Store" stopProcessing="true">
<match url="^store(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http://freertool.com{R:1}" />
</rule>
<rule name="Store Redirect www and en" enabled="true">
<match url="^www.freertool.com/store/en/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="http://freertool.com{R:1}" />
</rule>
</rules>
Related
The app is built on asp.net core 3.1 and react. They are on the same origin.
In web.config redirection from http to https working.
In web.config redirection from www.example.com to example.com not working
// Piece of my web.config
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="RedirectWwwToNonWww" stopProcessing="false">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
In browser www.example.com goes in redirection loop and shows
ERR_TOO_MANY_REDIRECTS
In Postman the error is Error: Exceeded maxRedirects. Probably stuck in a redirect loop https://www.example.com/
You can try this rule to redirect from www to none-www:
<rule name="SecureRedirect" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}" redirectType="Permanent" />
</rule>
Having a tough time configuring rewrite rules.
I basically want :
Non www requests to be redirected to one with www
Non https requests should be redirected to one with https
Desired Redirects:
Requested Url Redirected To
http://example.com https://www.example.com/
http://www.example.com https://www.example.com/
https://example.com https://www.example.com/
https://www.example.com https://www.example.com/
Rewrite configuration 1:
<rules>
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
<!--redirect to https -->
</rule>
<rule name="Add WWW prefix" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/" />
</rule>
</rules>
Rewrite configuration 2: (from IIS Redirect non-www to www AND http to https).
<rules>
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
The issue is mainly with https://example.com - it's not directing properly
Try this:
<rules>
<rule name="Redirect example.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Redirect to example.com https" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
Given this URL:
http://domain1.com/pdfs/file.pdf
How can I redirect domain1 to domain2 using the pdfs/* pattern?
I am trying to redirect http://domain1.com/pdfs/file.pdf to http://domain2.com/pdfs/file.pdf
I have tried:
<rule name="Publications" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^pdfs/$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://domain2.com/pdfs/{R:0}" />
</rule>
Thanks
I found it.
<rule name="Publications" enabled="true" stopProcessing="true">
<match url="^pdfs/(.*)" ignoreCase="true" />
<action type="Redirect" url="http://domain2.com/pdfs/{R:1}" />
</rule>
I have a rule
<rule name="HTTPS to HTTP Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="on" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
that redirects ALL HTTPS to HTTP however I now need 1 page to be HTTPS.
Thanks
Try this. I have assumed your page that is to force HTTPS is login.aspx.
<rewrite>
<rules>
<rule name="Force HTTPS for 1 page " stopProcessing="true">
<match url="(.*)/login.aspx" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Others Force HTTP" stopProcessing="true">
<match url="((.*))" negate="true" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Hi you can try regular expression below: This will match everything with https except for help.html page.
^[hH][Tt]{2}[pP][Ss](?!.*help.html).*$
In our web.config file we control 6 different international domains.
How do we do the following with 1 rule:
Redirect
www.1of6Domains.com/index.htm
www.1of6Domains.com/index.html
www.1of6Domains.com/default.asp
www.1of6Domains.com/default.aspx
to
www.1of6Domains.com
Something like this?
<rule name="Canonical Redirect" enabled="true" stopProcessing="true">
<match url="(.*)/(index.html|index.htm|default.asp|default.aspx)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="{R:1}" />
</rule>
I would go with:
<rule name="Canonical Redirect" enabled="true" stopProcessing="true">
<match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
<action type="Redirect" url="/" />
</rule>
If by saying www.1of6Domains.com you mean each domain might be different then action must be (bear in mind that it assumes non https traffic):
<action type="Redirect" url="http://www.1of6Domains.com" />
EDIT:
Here are the rules to handle multiple domains (it's possible with one rule, but rewrite map would need to be created, not sure you want that complication):
<rule name="Canonical Redirect Non Https">
<match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
<action type="Rewrite" url="http://{HTTP_HOST}/" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
</rule>
<rule name="Canonical Redirect Https">
<match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" />
<action type="Rewrite" url="https://{HTTP_HOST}/" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
</rule>