Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Servers > Internet Information Services
|
Internet Information Services Limit this to IIS questions and posts. ASP/ASP.NET questions should still go in the ASP/ASP.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Internet Information Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 10th, 2013, 02:36 AM
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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rewrite URL for subdomain phuc2583 ASP.NET 3.5 Professionals 0 November 26th, 2009 09:22 PM
URL Rewrite kumiko Classic ASP Basics 1 April 17th, 2008 01:05 AM
rewrite problem twr195 Beginning PHP 1 March 11th, 2008 12:49 PM
isapi url rewrite question rykiel Classic ASP Professional 0 October 9th, 2007 03:22 AM
problem with URL rewrite mlcy ASP.NET 2.0 Professional 3 June 21st, 2007 06:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.