Search
Home IIS.NET Forums IIS 7 & IIS 8 URL Rewrite Module Changing server name for one web directory
Last post Apr 17, 2012 11:55 AM by Leo Tang - MSFT
1 Post
Apr 13, 2012 12:26 PM|LINK
Hi folks, could anyone please help with a rewrite rule?
if a user accesses http://intranet/test then should be redirected to https://extranet/test but no other directory should be redirected. Also if a user directly accesses a file like http://intranet/test/file.doc should be redirected to http://extranet/test/file.doc
Thank you all for any help,
Regards, Marek
4161 Posts
Microsoft
Apr 17, 2012 11:55 AM|LINK
Hi,
You can add the following rule to the web.config file in your site root.
<rewrite> <rules> <rule name="ForTest" stopProcessing="true"> <match url="^test(/.*)?$" /> <conditions> <add input="{HTTP_HOST}" pattern="^intranet$" /> </conditions> <action type="Redirect" url="http://extranet/{R:0}" /> </rule> </rules> </rewrite>
http://learn.iis.net/page.aspx/734/url-rewrite-module/
If you encounter any problem, please update here.
marekchmel
1 Post
Changing server name for one web directory
Apr 13, 2012 12:26 PM|LINK
Hi folks, could anyone please help with a rewrite rule?
if a user accesses http://intranet/test then should be redirected to https://extranet/test but no other directory should be redirected. Also if a user directly accesses a file like http://intranet/test/file.doc should be redirected to http://extranet/test/file.doc
Thank you all for any help,
Regards, Marek
Leo Tang - M...
4161 Posts
Microsoft
Re: Changing server name for one web directory
Apr 17, 2012 11:55 AM|LINK
Hi,
You can add the following rule to the web.config file in your site root.
<rewrite>
<rules>
<rule name="ForTest" stopProcessing="true">
<match url="^test(/.*)?$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^intranet$" />
</conditions>
<action type="Redirect" url="http://extranet/{R:0}" />
</rule>
</rules>
</rewrite>
http://learn.iis.net/page.aspx/734/url-rewrite-module/
If you encounter any problem, please update here.
Feedback to us
Develop and promote your apps in Windows Store