g1smd - 12:20 am on Sep 8, 2012 (gmt 0)
In a recent site migration to extensionless URLs, requests for any of the old URLs with
?id=<num> parameters were rewritten to a PHP script. The script looked up the new URL in an array and used the PHP
HEADER directive to send a 301 redirect.
Those internal rewrites appeared right at the beginning of the htaccess file, a long way before the non-www to www redirect. To avoid a double redirect, the general canonical redirect further down the file also excluded requests that included these parameters from being redirected within the htaccess. This was done with a
RewriteCond. Without this condition, the internal rewritten path would be exposed back out on to the web as a new URL when non-www URLs are requested.
The htaccess file also contained a variety of other redirects for old pages that have moved and various mis-spellings, etc. These appeared after the special rewrites and before the general canonical redirect.
The final chunk of code in the htaccess file contained the various internal rewrites that kick in when the new extensionless URLs are requested.
Some 55 000 URLs have been migrated. It took Google 3 months to completely get with the program. Traffic also trebled.