Re: Need help with 301 redirect and mod_rewrite
Redirection using .htaccess is quite simple, keep 3 things in mind:
1) Do you have POST variables to these old urls, while posting a variables, it will lose values.
2) Make sure you don't lose the value of links that old urls had but doing proper redirection.
3) Links from internal pages needs to change to new urls as fast as possible to improve user experience.
Lets take things one by one:
news.php?id=4 , if the new urls in a pattern like something-4.html, it can be done at .htaccess like
RewriteRule news.php?id=(.*) /foldername/$1.html [R=301,L]
Now if the new URLs doesn't have a pattern
RewriteRule news.php?id=(.*) /redirect/index.php?id=$1 [L]
Now the redirect/index.php can get the new url from the DB and do a 301 redirection.
Folder redirection can happen like
RewriteRule ^/oldfolder/(.*) http://domain.tld/newfolder/$1
More matching and complex things can be done with referring variables from condition comparisons. Do let me know if you need more help.
Regards,
Aji Issac
|