I'm trying to redirect pages on a site who don't exist anymore to another page.
The problem is with the 3 languages we built our site in. I've created 3 rules.
To redirect without the language in the url (works perfectly!)
To redirect with the language "en":
<rule name="Redirect "en"" stopProcessing="true">
<match url="(.*)/([a-zA-Z]{2})/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{R:2}{C:1}" appendQueryString="false" />
</rule>
To redirect with the languages "nl-be" and "fr-be":
<rule name="Redirect "nl-be"/"fr-be"" stopProcessing="true">
<match url="/([a-zA-Z]{2}\-[a-zA-Z]{2})/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true" />
<action type="Redirect" url="/{R:1}/{C:1}" />
</rule>
They should all use the same rewrite maps, just copy over the language-part of the url.
This is an example of the rewrite map:
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/maptest" value="/flights" />
</rewriteMap>
</rewriteMaps>
I hope you guys can help me.
greetings, and thnx in advance!
Related
I am a fairly novice windows IIS guy, so any help I would greatly appreciate.
I have a client that requested all root Urls on their department websites redirect to their index.html page. So if a user, for example, goes to https://mysite.domain.com/, it will redirect to https://mysite.doman.com/index.html.
I did this through IIS 10 using a URLrewrite rule on the root of each site by doing the following.
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="https://mysite.domain.com/index.html" />
</rule>
This seemed to work.
The client now wants to have any of the subfolders of the root site show the index.html to any subdirectory sites of the root. Example. Https://mysite.domain.com/subdir/ “This is what shows now” to https://mysite.domain.com/subdir/index.html. Is there a way to do this in IIS?
Thanks in advance for any advice
I have made sure the index.html is the default document. I have also looked at User Friendly URL-template https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/user-friendly-url-rule-template, but I am not sure if this is the right direction to go.
You can try this rule:
<rule name="test" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/index.html" />
</rule>
<rule name="test1" enabled="true" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/([^/]+)" />
</conditions>
<action type="Redirect" url="/{C:1}/index.html" />
</rule>
<rule name="SEF Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}/index.html" matchType="IsFile"
ignoreCase="false" />
</conditions>
<action type="Redirect" url="{R:1}/index.html" />
</rule>
I want to write redirect rules in IIS 10. I googled it but could not found proper solution.
I have added some more scenarios.
https://testing.app.com/apptest should redirect to https://testing.app.com/apptest/account/login
https://testing.app.com/apptest/ should redirect to https://testing.app.com/apptest/account/login
https://test-apptest.testing.app.com/ should redirect to https://test-apptest.testing.app.com/account/login
https://test-apptest.testing.app.com should redirect to https://test-apptest.testing.app.com/account/login
Appreciated if someone can please help me with this.
What I tried so far is:
<rewrite>
<rules>
<rule name="Test1" stopProcessing="true">
<match url="apptest/login" />
<action type="None" />
</rule>
<rule name="login">
<match url="^apptest" />
<action type="Redirect" url="testing.app.com/apptest/login" appendQueryString="false" />
</rule>
</rules>
</rewrite>
You can try the rule below:
<rule name="test5" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="testing.app.com" />
<add input="{REQUEST_URI}" pattern="^/apptest$" />
</conditions>
<action type="Redirect" url="https://www.google.com/" appendQueryString="false" />
</rule>
I'm trying to simply do a subdomain rewrite to a directory. Example, http*://member.mydomain.com would redirect to http*://mydomain.com/memberarea/. I don't want ALL subdomains to do this, just the defined "member" one.
Here is the code I have, and it does not work. I'm obviously missing something...
<rule name="Member Pages" stopProcessing="true">
<match url="^(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*)://member\.example\.com($)" />
</conditions>
<action type="Redirect" url="{C:1}://example.com/MemberArea/{R:1}" />
</rule>
My hope is this would also make http://member.example.com/Report/SomeReport.aspx resolve to http://example.com/MemberArea/Report/SomeReport.aspx.
Any help would be greatly appreciated.
You can try this rule will be redirected to the http*://member.mydomain.com http*://mydomain.com/memberarea/
<rule name="test2" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^member\.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/memberarea" />
</rule>
I have a site that uses two characters in the URL path to determine the initial language e.g. https://my.company.net/Monitoring/gb displays in the English language. I want to setup a redirect for these two display the full culture code e.g. https://my.company.net/Monitoring/en-GB
This is the rule that I've tried:
<rewrite>
<rules>
<rule name="Monitoring gb rewrite" patternSyntax="ExactMatch" stopProcessing="true">
<match url="https://my.company.net/Monitoring/gb" />
<conditions />
<serverVariables />
<action type="Redirect" url="https://my.company.net/Monitoring/en-GB" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I expected https://my.company.net/Monitoring/gb to redirect to https://my.company.net/Monitoring/en-GB however this rule does not have any effect: the browser URL stays at https://my.company.net/Monitoring/gb.
How can I rectify this?
You could use below url rewrite rule.
<rule name="gb to en-gb redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="ww.sample1.com" />
<add input="{HTTPS}" pattern="on" />
<add input="{REQUEST_URI}" pattern="Monitoring/gb" />
</conditions>
<action type="Redirect" url="https://www.sample1.com/Monitoring/en-GB" />
</rule>
Note: use your hostname instead of the www.sample1.com.
The redirect failure was due to browser caching. The redirect works once the cache is cleared.
Why isn't this rule working when I go to a browser with the URL rewrite module?
It works on the regex tester with the url rewrite module.
I even put it at the top of all my rules.
Example url: organizations/51/middle-tennessee-basketball-showcases-basketball-tournaments?page=1
Rewrite rule:
<rule name="Organization Redirect" stopProcessing="true">
<match url="^organizations/(.*)-basketball-tournaments\?page=1$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>
Your rule should be as following:
<rule name="Organization Redirect" stopProcessing="true">
<match url="^organizations/(.*)-basketball-tournaments$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^page=1$" />
</conditions>
<action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>
You should not check the query string (here page=1) in the url test but in the conditions section.