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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.