1

I want to redirect all request from a url host www.hostname1.com (including all subdirectores-www.hostname1.com/....) to a different url with a different host, www.newHost.com. I have already made the change in the DNS but am wondering what changes I should make on the server on which www.newHost.com is hosted so that the redirect takes place with the new url displayed on the browser.

I have look at the IIS. Under the configurations for www.newHost.com, I can bind www.hostname1.com to the same IP as www.newHost.com but this works only for the home page for www.hostname1.com and does not rewrite the url address in the browser window.

Please advise on how to make this change.

user207265
  • 11
  • 2

2 Answers2

0

On the new server, under the www.hostname1.com site (the one you created on the new server to catch traffic to the old site after the DNS change), use this as your entire web.config file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="301 redirect entire site" stopProcessing="true">
                    <match url="^(.*)$" />
                    <action type="Redirect" redirectType="Permanent" url="http://www.newhost.com/{R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

That will create a rewrite rule that grabs the entire content of the URL (after the http://www.hostname1.com/), puts "http://www.newhost.com/" in front of it and any query string on the end, and redirects the browser to that URL. This is a 301 redirect (permanent), so it should be SEO safe so Google doesn't punish your ranking. I haven't tested this, but I think it should work for you.

kevinmicke
  • 411
  • 1
  • 4
  • 17
0

You can create an htaccess file in IIS root directoryand make this redirection happen

IfModule mod_rewrite.c>   RewriteEngine On   RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]   RewriteCond %{HTTP_HOST} ^www.olddomain.com$   RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]

This will direct all your traffic to the new domain.

Manikandan Ram
  • 399
  • 2
  • 15