Forum Moderators: phranque
From my understanding, the check list is this...
1. Get the website ready
2. Do the redirect code
3. Disconnect the DNS and move it over to the new site.
I have some specific questions based on this checklist.
When doing the redirect, I'm very much resigned to the fact that I will have to do a one-by-one redirect for the URLs to make sure they line up correctly (I doubt I can do a mod-rewrite on this).
For instance, the URL for the original website would be something like this.
http://www.example.com/CPU-fan.asp
The PHP page that the URL will be redirected to will be...
http://example.newhostingcompany.net/Categories/193/3899/
Now, I already know that the URLs are not SEO friendly, but that's beside the point, and a long story I can't get into right now.
I so far have yet to see an example of a PHP redirect code (either on the .htaccess page, or at the top of the web page), where it specifically spells out how to redirect to very specific pages beyond the basic URL. Normal examples usually look like this...
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
Now, if it is that simple, than great, but I'm getting the impression that it's not. I would expect it to looks somewhere along the lines of...
(The OLD URL is) http://www.example.com/CPU-fan.asp (but is now->) (The NEW URL) http://example.newhostingcompany.net/Categories/193/3899/
Repeat as necessary with all of the listings as indexed by Google (beyond what's indexed, what's the point), and then apply the original DNS (http://www.example.com) to the hosting company's sub-domain (http://example.newhostingcompany.net/) afterward.
But the point is...
1. ...what does the syntax on the code look like in PHP in an .htaccess file (I've only seen one example, but it has 3 HTTP requests in it. I need an example that just does everything in one fell swoop)?
2. Also, when I do a header location per the above example ("Location:http://www.new-url.com"), do I route it to the current hosting company's subdomain ("http://example.newhostingcompany.net/")...
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://example.newhostingcompany.net/" );
?>
...and then disconnnect the DNS from the ASP site and then overlay the current DNS over the hosting company's URL ("http://example.newhostingcompany.net/").
OR
do I just simply route it to the current domain FIRST in the PHP header code ("http://www.example.com/")
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com/" );
?>
and then disconnect the DNS from the ASP site to the PHP site, and let it resolve afterwards?
BTW, I am a newbie, taking over for a previous admin that bailed on us at the last minute, so getting someone who knows PHP and SEO is not a viable alternative right now. I'm all these people got so please be patient with me when I request additional information.
[edited by: jdMorgan at 2:00 am (utc) on June 24, 2009]
[edit reason] example.com [/edit]
Your code is PHP. It would NOT go inside the .htaccess file.
You have several ways to tackle this. Either:
- use multiple RewriteRules in .htaccess, to each redirect one URL or group of URLs.
- identify unique patterns that match old URLs and rewrite those to a PHP script that then sends out the correct HTTP headers (like your code above).
Before doing any of that, you need to compile a very comprehensive list of old and new URLs.
.
Setting this up you would:
- change the DNS TTL to a very low value a few days before the move is scheduled.
- stop people posting information to the old site (if it uses a database).
- set up the new site on the new server (using the recently copied database).
- add all the redirect code to the new server so that as soon as it is live, people see and follow the redirects.
- put a note on the old server that "the site is moving hosts", and that "when you no longer see this message the move is complete".
- change the DNS and allow at least two or three days for everyone to no longer be accessing the old site.
- take down the old site.
I think I nailed all the steps that you need.
.
*** I've only seen one example, but it has 3 HTTP requests in it. I need an example that just does everything in one fell swoop ***
You identify an important point here. Any redirect should take the visitor from old URL to new URL in just one step, never via a Redirection Chain.
I'm looking through this and I'm still somewhat at a loss [httpd.apache.org ]
RewriteRule ^first-old-page\.asp$ http://example.com/unrelated-new-page.php [R=301,L]
RewriteRule ^another-old-page\.asp$ http://example.com/dissimilar-new-page.php [R=301,L]
RewriteRule ^additional-old-page\.asp$ http://example.com/diffirent-new-page.php [R=301,L]
... etc.
If you do end up writing one rule for every URL on the old site and there are several hundred of them, then you may want to look carefully at the server stats: Consider redirecting only the top-traffic and top-ranked pages and letting the others go 404-Not Found in the interest of not bogging down the new server. It is likely that you will want to keep the remaining redirects in place for years -- or for as long as it takes for the most important third-party links to them to disappear, get updated, or become irrelevant to the ranking of the new pages.
Try to actually design the new site's URL architecture so that the new page URLs will never ever need to be changed again, even if you again change server technology. One step in doing this is to use extensionless page URLs -- e.g. example.com/page instead of example.com/page.php or example.com/page.asp. More here [w3.org].
Jim