Support » Fixing WordPress » One wp to a new wp same server migration

  • Dear WordPress…please can you help?

    Basically I have been building a new wordpress website in a directory called http://rhinoaluminium.co.uk/home

    My OLD website has always run out of another directory – http://rhinoaluminium.co.uk/public.

    So basically the OLD site is my domain /public and the NEW site is my domain /home.

    I am now ready to switch to the new site (publically) and have added a redirect rule on my server which sends all web traffic that wants to go to the root domain http://rhinoaluminium.co.uk (also with a www prefix) to the new home directory….this works just fine!

    Now…when I now add redirect rules for sub directories of the old site domain/public/contactus for example or if I go to the website http://rhinoaluminium.co.uk/public it DOES NOT redirect to the new site in the home directory, it just goes to the old domain ‘public’.

    I have read all of the articles online regarding moving domains and changing paths etc in wordpress, but none of them relate to this example, as I am NOT moving the wordpress installation, I am moving from one wordpress site to another on the same server.

    I think it’ll be something to do with a .htaccess file orsite address field on the old site, but i’m reluctant to touch these until I get some advice.

    Please could you offer some advice?

    Many thanks

    Andrew

Viewing 13 replies - 1 through 13 (of 13 total)
  • Your server is using APACHE then yes, you need to do a 301 (permanent) redirection using .htaccess to achieve what you want.

    Redirect 301 /public
    http://rhinoaluminium.co.uk/home

    Ok and thank you for the reply.

    Is this the .htaccess file in the root of public_html or the .htaccess in the root of the public folder?

    I do have a rediret rule in the root of my domain which states anything domain /public send to domain /home but if you go to http://rhinoaluminium.co.uk/public this rule does not work!?? It just goes to the old site.

    Any ideas?

    The .htaccess must be on the root (public_html in your case).

    Can you please share with us your .htaccess redirection rule, maybe something wrong with it

    ok thanks for looking, here’s my root .htaccess file:

    #suPHP_ConfigPath /home/rhino001/public_html
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^/?$ “http\:\/\/rhinoaluminium\.co\.uk\/home” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^sms\/?$ “http\:\/\/rhinoaluminium\.co\.uk\/sms\/index\.php” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/about\-rhino\-aluminium$ “http\:\/\/rhinoaluminium\.co\.uk\/home” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/our\-mission\-vision\-and\-values$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/mission\-vision\-and\-values\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/find\-an\-approved\-installer$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/find\-an\-approved\-installer\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/testimonials\/$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/testimonials\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/contact\/map\/$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/contact\-us\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/contact\/$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/contact\-us\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/rhino\-aluminium\-downloads$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/downloads\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/terms\-conditions$ “http\:\/\/rhinoaluminium\.co\.uk\/home\/terms\-conditions\/” [R=301,L]

    RewriteCond %{HTTP_HOST} ^rhinoaluminium\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.rhinoaluminium\.co\.uk$
    RewriteRule ^public\/$ “http\:\/\/www\.rhinoaluminium\.co\.uk\/home” [R=301,L]

    that’s a lot of rules :P, just replace it with theses 4 lines :

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/public/(.*)$
    RewriteRule ^(.*) http://rhinoaluminium.co.uk/home/%1 [R=301,NC]

    Thanks for the reply, but no this doesn’t work.

    using your 4 lines I get the following results:

    Going to rhinoaluminium.co.uk just brings up a file view (index page of text with links to other folders including public and home) but does not take you to /home.

    When you go to domain /public it doesn’t redirect to /home.

    I have all of those redirect in an attempt to send visitors to the new site page when they find google results for historic pages.

    The page structure and names do NOT match between the old and new site so wildcards will not work.

    Amny other ideas?

    Thanks for your help!

    Mmmh, i thought you have something under the main domain, Sorry 🙂
    Maybe this link helps you out to create .htaccess map redirection :
    http://www.htaccessredirect.net/

    I can’t understand why this issue hasn’t come up before and that people on here don’t just say…oh that’s easy just do this…So my plan now is to simply change each index.php in the old site (public folder) to redirect to each relevant page. I think this is going to be easier. Any opinions?

    I cannot see why this is hard, if both websites (installations) are using similar database and links-structure then just replacing the root domain name from zzz.com/yyy => zzz.com/xxx is enough.

    BUT if the links-structure and database are different in both websites then it will be very hard to maintain the migration.

    Ok and thanks for the reply.

    My link structure is different from the public site to the home site.

    I see you say it’ll be harder if they are different but no indication on what I would now need to do…any ideas?

    I have changed the index.php page to have a php script which redirects everything going to public to home, but this way I am losing the google results which offer up the old contact page etc…please somebody must have the answer?

    I thought about a php script that tested which page you came in on then redirected you via a case statement to the new page location????

    .htaccess can do this for you but if you are more comfortable with php then this is what you looking for :

    <?php
    
    header("HTTP/1.1 301 Moved Permanently");
    $current_url = 'http://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
    
    switch ($current_url) {
    	case 'http://rhinoaluminium.co.uk/public/contact':
    		$new_url = 'http://rhinoaluminium.co.uk/home/contact-us' ;
    		break;
    
    	case 'http://rhinoaluminium.co.uk/public/download':
    		$new_url = 'http://rhinoaluminium.co.uk/home/files' ;
    		break;
    
    	default:
    		$new_url = 'http://rhinoaluminium.co.uk/home' ;
    		break;
    }
    header("Location: ".$new_url);
    • This reply was modified 2 years, 2 months ago by  Sidati. Reason: Adding code wrapper
    • This reply was modified 2 years, 2 months ago by  Sidati.

    YES!

    Excellent work and thank you!

    The php script above works a charm and thank you!

    I know this was a ‘different’ way about resolving the migration and other people have their ways, but to solve this structure the code you gave is perfect! It stops me losing all those good SEO results!

    You’re welcome @mcdrewblue

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘One wp to a new wp same server migration’ is closed to new replies.