I have 2 URLs
http://test.mysite.com (1) and
http://test.mysite.com/app (2)
I would like to redirect requests to (1) to www.othersite.com
when (2) shuld not be redirected.
Is it possible to do with url rewrite using regex?
br
Yes, it is possible with URL rewrite module. Your rule looks like that:
<rule name="Redirect non app" stopProcessing="true">
<match url="^app(.*)" negate="true" />
<action type="Redirect" url="http://www.othersite.com{REQUEST_URI}" />
</rule>
Related
We would like to redirect IIS traffic with URL www.site1.com to www.site2.com. We do not want to redirect traffic for url's with either folder names and or script names. In other words we do NOT want to redirect a URL like www.site1.com/someFolder or www.site1.com/somePage.php, but if the URL is "plain" www.site1.com we want to redirect to www.site2.com.
You can try below rule:
<rule name="Redirect 1" enabled="true" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll">
</conditions>
<action type="Redirect" url="http://localhost:820/" appendQueryString="false" logRewrittenUrl="true" />
</rule>
you can set redirect URL based on your requirement
I have to domains - a.com and b.com. I want to use iis rewrite so that anything going to www.a.com/ will be redirected to www.b.com/index.asp?i=.
For example www.a.com/XXX will be redirected to www.b.com/index.asp?i=XXX
I put (.*?) in the pattern. The problem is when I enter http://www.b.com/index.asp?i={REQUEST_URI} as a redirect action, the redirect url includes a slash. For example www.a.com/XXX is redirected to www.b.com/index,asp?i=/XXX instead of to i=XXX. Is there any way to get rid of the slash?
You could use below url rewrite rule:
<rule name="test1" enabled="true" stopProcessing="true">
<match url=".+" />
<conditions>
</conditions>
<action type="Redirect" url="http://www.b.com/index.asp?i={R:0}" />
Regards,
Jalpa
I want my domain homepage to be redirected to one of my mvc directories
this is the rule i am using
<rule name="Home" stopProcessing="true">
<match url="^/*$" />
<action type="Rewrite" url="/test/" logRewrittenUrl="true" />
</rule>
Same rule is working if i put redirect. But rewrite is not working.
Other URLS should be served normally. Only home page should be rewritten
Can we achieve this without ARR?
//www.example.com should be rewritten to //www.example.com/test/
www.example.com/buy should be served as it is.
Your regex is incorrect. Correct rule is:
<rule name="Home" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/test/" logRewrittenUrl="true" />
</rule>
And this rule will work without ARR because you rewriting to a subfolder in the same website. If you want to rewrite to the different website in IIS, then you need ARR.
I have an old url www.mydomain.com/customer/1. I changed that server to ww2 and it displays fine at ww2.mydomain.com/customer/1. On my new IIS 8.5 www server how can I put in a rewrite rule so if the user goes to www.mydomain.com/customer/1 they will redirect to ww2.mydomain.com/customer/1. I have tried numerous patterns in the Url Rewrite 2.0 module and nothing seems to work. All other www requests I do not want redirected, those stay on my new www server.
I you want to redirect a single path, /customer/1, then you should add this to Web.config on the www.mydomain.com server:
<rewrite>
<rules>
<rule name="Redirect 'www.mydomain.com/customer/1' to 'ww2.mydomain.com/customer/1'" stopProcessing="true">
<match url="^customer/1$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mydomain\.com$" />
</conditions>
<action type="Redirect" url="http://ww2.mydomain.com{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
If you wish to include additional paths, you can fiddle with the RegEx specified in the <match url="^customer/1$" /> tag.
I need to create easy to remember URL's that redirect to long and hard to remember paths for a large number of applications.
i.e.
subdomain.domain.edu/shortname
redirects to
https://www.subdomain.domain.edu/mainApplication/subfolder/page
I'm using the URL Rewrite module in IIS 8.5, but I keep getting a 404 when I browse to the short alias. I know the rewrite module is working as I use it to handle rewriting HTTP to HTTPS and to add WWW to a URL.
My rewrite rule looks like:
<rewrite>
<rules>
<rule name="Easy to remember shortcut" stopProcessing="true">
<match url=".*subdomain.domain.edu/shortname" />
<conditions>
<add input="{URL}" pattern=".*/shortname" />
</conditions>
<action type="Redirect" url="https://www.subdomain.domain.edu/mainApplication/subfolder/page.aspx" />
</rule>
</rules>
</rewrite>
Of course this returns a 404. Any ideas?
Forgive me if there is already an answer to this in another post, however, I've read through and tried over 30 posts on the URL rewrite module and have not yet found the solution for actually creating an alias.
Url rewrite match condition won't be able to see your domain i.e. if the URL is https://www.subdomain.domain.edu/shortname the match part can only see shortname (anything after domainname/).
To validate the host we need to add in the conditions clause. So your rule will be something like below
<rule name="shortnameURL" enabled="true" stopProcessing="true">
<match url="shortname" />
<action type="Redirect" url="mainApplication/subfolder/page" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*subdomain.domain.edu" />
</conditions>
</rule>
Also it should be ok if you add the entire URL here
<action type="Redirect" url="mainApplication/subfolder/page" /> as below
<action type="Redirect" url="https://www.subdomain.domain.edu/mainApplication/subfolder/page" />