<rule name="List_of_mfrs" enabled="true">
<match url="/Manufacturers_(\w)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/list_of_mfrs/mfrs.cfm?ot={R:1}" />
</rule>
When I enter: http://MyLocalHost/list_of_mfrs/mfrs.cfm?ot=R It gets 404 error. Why?
I got why it happened: because of the character / in #type and #url
Here is the correct text:
<rule name="List_of_mfrs" enabled="true">
<match url="Manufacturers_(\w)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="list_of_mfrs/mfrs.cfm?ot={R:1}" />
</rule>
Related
I have this rule:
<rule name="301 Redirect 1" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="^/live-better/.*" negate="true" />
</conditions>
<action type="Redirect" url="https://www.example.com/business/live-better" redirectType="Permanent" />
</rule>
Which I want to work for the following:
www.test.com/live-better
www.test.com/live-better/page-one
www.test.com/live-better/page-two
and I want them to all redirect to the counterpart:
https://www.example.com/business/live-better
https://www.example.com/business/live-better/page-one
https://www.example.com/business/live-better/page-two
But my rule does not appear to work.
Does anyone know how I can get it to work?
you could try below rule:
<rule name="301 Redirect 1" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="^/live-better/(.*)" />
</conditions>
<action type="Redirect" url="https://www.example.com/business/live-better/{C:1}" redirectType="Permanent" />
</rule>
I am trying to redirect the two links below to the root.
My question is can you see a problem with my rule written below?
Thank You!
http://pollen.aaaai.org/nab/collectors/
http://pollen.aaaai.org/nab/collectors/index.cfm?p=Count_form
<rule name="Redirect /nab/collectors/ to http://pollen.aaaai.org/" patternSyntax="Wildcard" stopProcessing="false">
<match url="*/nab/collectors/*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Rewrite" url="http://pollen.aaaai.org" appendQueryString="false" />
</rule>
There is a problem with your parameter, it matches the content after the hostname and does not contain "/". you can refer to below rule about redirect to root.
Note: I changed patternSyntax from wildcards to regular expressions.
<rule name="Redirect /nab/collectors/ to http://pollen.aaaai.org/" patternSyntax="Regular Expressions" stopProcessing="false">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Rewrite" url="http://pollen.aaaai.org" appendQueryString="false" />
</rule>
I'd like to put a redirect in web.config from olddomain.com/en-us/abc/blahblah to newdomain.com/abc/blahblah
Meaning in addition to the change of domain, the new URL doesn't have /en-us/, and everything else remain the same.
I picked up from here and there and came up with the following code, but it doesn't work. Could you help?
<rule name="Redirect New Site" enabled="true" stopProcessing="true">
<match url="^/en-us/(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{PATH_INFO}" pattern="^/abc/(.*)" />
<add input="{HTTP_HOST}" pattern="^olddomain.com/$" />
</conditions>
<action type="Redirect" url="https://newdomain.com/{R:1}" redirectType="Permanent" />
</rule>
For this requirement, I test it in my side. You can use the <rule> like below:
<rule name="redirectRule1" enabled="true" stopProcessing="true">
<match url="^en-us/(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^olddomain$" />
</conditions>
<action type="Redirect" url="http://newdomain.com/{R:1}" />
</rule>
Here is the rule and test result in my side. The <rule> in my web.config is:
<rule name="redirectRule1" enabled="true" stopProcessing="true">
<match url="^en-us/(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^localhost:49293$" />
</conditions>
<action type="Redirect" url="http://newdomain.com/{R:1}" />
</rule>
Please note my old domain is localhost:49293.
Then when I request the url http://localhost:49293/en-us/Upload, it will redirect to new url http://newdomain.com/Upload(without en-us).
============================Update============================
<rule name="redirectRule1" enabled="true" stopProcessing="true">
<match url="^en-us/abc/(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^olddomain$" />
</conditions>
<action type="Redirect" url="http://newdomain.com/abc/{R:1}" />
</rule>
I would like to use part of the filename as a folder name, my redirect is working but the rewrite does not work, this is my web.config (also has a rule to remove the file extension):
Original: https://www.ipressnet.com.br/v6/client_tracking.aspx?id=x
Rewrite: https://www.ipressnet.com.br/v6/client/tracking?id=x
THIS WORKS:
<rule name="RemoveASPx" enabled="true" stopProcessing="false">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="AddASPx" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
THIS DOES NOT WORK:
<rule name="RemoveClient" enabled="true" stopProcessing="false">
<match url="^v6/?$|^client_(.*)$" />
<action type="Redirect" url="client/{R:1}" />
</rule>
<rule name="AddClient" enabled="true">
<match url="^v6/client/(.*)$" negate="false" />
<action type="Rewrite" url="v6/client_{R:1}.aspx" />
</rule>
I appreciate any help, thank you!
You can write RemoveASPx and RemoveClient in the same rule.
The following rule maybe achieve your requirement.
<rule name="rewrite rule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^/v6(.*)client_(.*)\.aspx$" />
</conditions>
<action type="Redirect" url="v6{C:1}client/{C:2}" redirectType="Temporary" />
</rule>
<rule name="(.*)" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^/v6/client/(.*)" />
</conditions>
<action type="Rewrite" url="v6/client_{C:1}.aspx" />
</rule>
<rule name="r1" stopProcessing="true">
<match url="v6/(client)?(_)?(.*).aspx" ignoreCase="false" />
<action type="Rewrite" url="v6/{R:1}/{R:3}" />
</rule>
I have 2 custom domains set up on Azure Websites:
mydomain.lt and www.mydomain.lt
DNS registrar's settings:
Subdomain and redirect:
awverif -> CNAME: awverify.mydomain.azurewebsites.net
www -> CNAME: mydomain.azurewebsites.net
Other redirects:
IP: 137.x.x.x (IP address provided by Azure) and MX: 79.x.x.x
I can reach my website via mydomain.lt and www.mydomain.lt
What I am trying to do now is to set my Canonical URL in a way, that users coming from
www.mydomain.lt would be automatically redirected to mydomain.lt and all relative URL paths returned in a lower case.
I added settings bellow to system.WebServer on Web.config:
<rewrite>
<rules>
<!-- SEO | Section 1 | Whitelist -->
<rule name="Whitelist - Resources" stopProcessing="true">
<match url="^(?:css/|scripts/|bundles/|images/|install/|config/|umbraco/|umbraco_client/|base/|webresource\.axd|scriptresource\.axd|__browserLink|[^/]*/arterySignalR/.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<!-- SEO | Section 2 | Rewrites (chaining) -->
<rule name="SEO - Lower case" stopProcessing="false">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_METHOD}" pattern="GET" />
<add input="{R:1}" pattern="[A-Z]" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="_{ToLower:{R:1}}" />
</rule>
<!-- SEO | Section 3 | Redirecting -->
<rule name="SEO - HTTP canonical redirect" stopProcessing="true">
<match url="^(_*)(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^www\.(.*)" />
<add input="{HTTP_METHOD}" pattern="GET" />
<add input="{SERVER_PORT}" pattern="80" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:2}" />
</rule>
<rule name="SEO - Non-canonical redirect" stopProcessing="true">
<match url="^(_+)(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_METHOD}" pattern="GET" />
</conditions>
<action type="Redirect" url="{R:2}" />
</rule>
</rules>
</rewrite>
The resulting behaviour is a redirect loop. Any ideas how to fix this problem?
It seems the problem is with Azure Websites. The link below gives a workaround how to fix the problem temporarily.
http://social.msdn.microsoft.com/Forums/wpapps/en-US/ee3a5f97-8a58-4b42-a2d9-a73cd5d12c01/issues-with-redirect-rules-used-in-url-rewrite-feature?forum=windowsazurewebsitespreview
I've rewritten my rules and everything works just fine:
<rewrite>
<rules>
<rule name="Whitelist - Resources" stopProcessing="true">
<match url="^(?:css/|scripts/|bundles/|content/|images/|install/|config/|umbraco/|umbraco_client/|base/|webresource\.axd|scriptresource\.axd|__browserLink|[^/]*/arterySignalR/.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<rule name="Convert to lower case" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
<rule name="Canonical Host Name" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll">
<add input="{REMOTE_PORT}" pattern="*" />
<add input="{HTTP_HOST}" pattern="mydomain.lt" negate="true" />
</conditions>
<action type="Redirect" url="http://mydomain.lt/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Start by simplifying your rewrite rules to narrow down the problem:
Instead of using rewrite for www, just update the CNAME for www.domain.com to point to domain.com
remove section 3 till you get section 2 working
then try updating section 2 to:
<!-- SEO | Section 2 | Rewrites (chaining) -->
<rule name="SEO - Lower case" stopProcessing="false">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_METHOD}" pattern="GET" />
<add input="{R:1}" pattern="[A-Z]" ignoreCase="false" />
</conditions>
<action type="Redirect" url="{ToLower:{R:1}}" RedirectType="Permanent"/>
</rule>