Forum Moderators: phranque
I'm in the process of cleaning up some URLs on one of my sites. Wanted to run my code by the experts, see if I'm doing this right.
Goal: Migrate my long (and ugly) URLs to a cleaner URL without losing any search rank.
# 301 to the new sleaker URL:
RewriteCond %{REQUEST_FILENAME} find_celeb_information
RewriteCond %{QUERY_STRING} celeb=([^&;]*)
RewriteRule ^find_celeb_information.php /people/%1? [R=301,L]# Re-write it back to orignal script (non-301)
RewriteRule ^people/(.*) new_celeb_info.php?star=$1 [L]
To avoid problems, I copied "find_celeb_information.php" to "new_celeb_info.php". So first I redirect all old requests to "find_celeb_information.php" to the new version in the "people" directory.
Next I then redirect that request to the copied original script (now called "new_celeb_info.php").
It seems to work fine. My old URLs (using "find_celeb_information.php") redirect to the new URL format.
Am I doing this properly if I want to tell the search engines that the old pages (using "find_celeb_information.php") have now moved to the new format in the "people" directory? I want to try and have minimal affect on my rankings.
Thanks for any advice!
# Redirect old dynamic URLs to new search-friendly URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /find_celeb_information\.php\?([^&]+&)*celeb=([^&\ ]*)\ HTTP/
RewriteRule ^find_celeb_information\.php http://www.example.com/people/%2? [R=301,L]
I removed the semicolon from the negative-match subpattern on your query string. If you use semicolons as name/value pair delimiters instead of ampersands, then put change all ampersands to semicolons instead.
Jim