• Hello,

    I have an old WPMu 2.7 site (www.domain.com/my_old_site), and I want to have all pages/posts and files in that site to redirect to my new site’s homepage. I tried doing this in index.php

    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: https://www.new_site.com");
    ?>

    But it only works for that one page. If I change all the instances of the URL in the old site’s site settings, would that do the trick, or is there a better practice for this?

    Thanks a lot.

Viewing 7 replies - 1 through 7 (of 7 total)
  • @moose1:

    You can try using a .htaccess file instead.

    Save the following in a .htaccess file or modify and existing file and upload to your site… Remember to do a backup of your old .htaccess file (if any) first…

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.olddomain.com$
    RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]

    Thread Starter moose1

    (@moose1)

    Hi Gerald,

    Thanks for the tip! I just tried doing a redirect with .htaccess by putting the file in the main directory of the theme of the site that I want to redirect (since it’s an Mu site) but it’s still only re-directing the index.php page.

    Since I’m re-directing from an Mu install, would I put the .htaccess file in the root of the main site instead?

    Cheers,
    moose

    @moose1:

    I ain’t very familiar with WPMU, but you can try moving it to the main directory /root site since the RewriteCond should ensure that the proper domain is the one being redirected. This rewrite rule should be above other rewrite rules you may already have.

    As always, do backup your current .htaccess files first…

    not sure whether you have any SEO values for your site but 301 will definitely damage it.

    Just a tip

    @mralexander.Ca

    On the contrary, 301 is the recommended way to tell a search engine that the resource has been moved…

    301 implies that it has moved permanently. Search Engines would therefore transfer whatever link popularity that the original had to the new one.

    If this was a 302 or 404, the situation will be different.

    Thread Starter moose1

    (@moose1)

    Thanks all for the tips. I forgot that I could do this via cPanel, which creates the redirect in .htaccess automatically. So, this is what I got now.

    RewriteCond %{HTTP_HOST} ^my_old_site.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.my_old_site.com$
    RewriteRule ^my_blob/?(.*)$ "http\:\/\/new_site\.com\/$1" [R=301,L]

    I put this in the root of my Mu install but still it’s not working. I’ll mess around with it some more and report my results.

    Thanks again.

    Thread Starter moose1

    (@moose1)

    So I just couldn’t get htaccess to do what I wanted, so I went with my original option, which was to do a php redirect.

    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: https://www.new_site.com");
    ?>

    My mistake before was putting it index.php, which is why it only worked for that one page (duh). Adding it to header.php covers all pages posts.

    Thanks again.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Redirect all old pages to new domain’ is closed to new replies.