View Single Post
  #1 (permalink)  
Old July 10th, 2013, 02:36 AM
CompactDisc20 CompactDisc20 is offline
Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default URL Rewrite (hostname rewrite) not working

Hello folks, I am having an issue trying to rewrite an URL.

This is the scenario. I have a new website that is replacing an old website (each one in a separate server). The new site is up and running and we want to redirect users that are still going
to the old website to the new site. So we changed DNS of the old site to point to the IP of the new site. However, we want to rewrite the old hostname in the URL to the new hostname we are
using for the new site.

newsite.mylcl.lan
oldsite.mylcl.lan

The new site is running IIS 7.5 and I installed URL Rewriter 2.0 without any problems.

I have tried this using rewrite and redirect rules, none of them are working, here are the two rules I have tried:

REDIRECT RULE

<system.webServer>
<rewrite>
<rules>
<rule name=”Redirect” stopProcessing=”true”>
<match url=”.*” />
<conditions>
<add input=”{HTTP_HOST}” pattern=”^oldsite.mylcl.lan$” />
</conditions>
<action type=”Redirect” url=”http://newsite.mylcl.lan/{R:0}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>



REWRITE RULE

<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^oldsite.mylcl.lan$" />
</conditions>
<action type="Rewrite" url="http://newsite.mylcl.lan/{R:0}" appendQueryString="false" />
</rule>
</rules>

</rewrite>

When I type the old site URL in my browser, it goes to the new site, however, the old site URL remains in the address bar and it is not rewritten.

When it comes to regular expressions, I am an ignorant, so I am pretty sure I got something wrong here. However, I based these rules on some examples I found on the Internet.

Most of the examples I found are instruction on how to rewrite an URL for the same website, so the hostname of the URL is not rewriten/touched at all. But as you can see, in my
case, what I need to rewrite is the hostname.

I really appreciate your help on this issue, I have been going crazy and don' know where else to look on how to accomplish this.

Thanks!
Reply With Quote