0

When I installed Wordpress I decided on what I thought would be a decent URL and started writing blog posts and pointing people to www.moreGenericDomain.com/myblog/. Everything worked, and still works, fine. But as my blog focus was narrowed the domain didn't quite suit it anymore.

I've since purchased a new domain that I would like to use. When I go into settings and set www.NewDomain.com as the blog address everything works fine for that domain. Further, the urls are cleaner as they have changed from www.moreGenericDomain.com/myblog/post-1 to www.NewDomain.com/post-1. So everything seemed to go going great.

However, after this change www.moreGenericDomain.com/myblog/post-1 would give a Wordpress 404 page. This is very undesirable as I already have a number of links to my blog posts and a few initial subscribers. I don't want to lose this established traffic that I've worked so hard for.

Is it possible to switch to the new domain name while keeping the old one functional? In other words, I would like www.moreGenericDomain.com/myblog/post-1 to redirect to www.NewDomain.com/post-1.

Update

Per some helpful tips in the comments I tried setting up rewrite rules. My web.config looks like this:

    <rewrite>
        <rules>
            <rule name="multAccounts">
                <match url="http://oldDomain.com/LMBlog/post-1/" />
                <action type="Rewrite" url="http://newDomain.com/post-1/" />
            </rule>
            <rule name="darkEssences">
                <match url="http://oldDomain.com/LMBlog/post-2/" />
                <action type="Rewrite" url="http://newDomain.com/post-2/" />
            </rule>
            <rule name="GuildBash">
                <match url="http://oldDomain.com/LMBlog/post-3/" />
                <action type="Rewrite" url="http://newDomain.com/post-3/" />
            </rule>
            <rule name="KvK">
                <match url="http://oldDomain.com/LMBlog/post-4/" />
                <action type="Rewrite" url="http://newDomain.com/post-4/" />
            </rule>
        </rules>
    </rewrite>

The first rule seems to work correctly, while IIS ignores the other 3. I've used IIS' rule editor to test my input URL and it says it matches, but when I go to that URL I am not redirected and Wordpress gives me a 404.

I also tried a regex rule:

        <rules>
            <rule name="RegexRewrite">
                <match url="([a-zA-Z\-\:\/]+)oldDomain.com\/lmblog\/([a-zA-Z\-]+)" />
                <action type="Rewrite" url="http://NewDomain.com/{R:2}" />
            </rule>
        </rules>

However, that is completely ignored; no rewrites occur at all and I received the Wordpress 404 page. I suspect that Wordpress is preventing IIS from doing url rewrites.

Nicholas
  • 1,974
  • 4
  • 20
  • 46
  • 1
    You can do that with .htaccess on the old domains root folder. [Check this](https://stackoverflow.com/questions/1945568/htaccess-redirect-all-pages-to-new-domain). – Gregor Ojstersek Jun 16 '18 at 21:36
  • @GregorOjstersek Thanks. Both domain names are bound to the same IIS site. Will that cause a problem with this approach? – Nicholas Jun 18 '18 at 03:25
  • Yes. IIS is a total different story. You would need to tweak the web.config file to make the redirection on the root of the site. https://stackoverflow.com/questions/32648449/301-redirect-one-domain-to-another-using-web-config – Gregor Ojstersek Jun 18 '18 at 07:32

0 Answers0