Hi, I'm struddling with 301 redirects. I have an existing site structure that uses mod rewrite to give me SEO-friendly pages, however the existing structure isn't very nice so I'm re-writing the code to allow for a better structure. The problem I have is I don't know how to do 301 redirects for re-writen urls. E.g.: I currently have a page like: xhttp://www.animal-care.co.uk/cats/abyssinian/breeds/articles/abyssinian-the-facts-every-owner-of-this-cat-breed-should-know.html This uses a htaccess file using this rule to re-write the path: RewriteRule ^([^/]+)/([^/]+)/([^/]+)/articles/([^/]+).html /articles.php?panimal=$1&animal=$2&articletag=$4 [NC] This page with the new code will have a new url of: xhttp://www.animal-care.co.uk/articles/abyssinian-the-facts-every-owner-of-this-cat-breed-should-know.html using this re-write rule: RewriteRule ^articles/([^/]+).html /article.php?article=$1 [NC] Note - the xhttp is just to prevent the url's from generating as links for this post I need to redirect the old url to the new one. Can I use a redirect rule to redirect the first url without having to write a rule for every page using the first rewrite rule?:
Try this: RewriteRule ^([^/]+)/([^/]+)/([^/]+)/articles/([^/]+).html http://www.animal-care.co.uk/articles/$4.html [R=301,L] RewriteRule ^articles/([^/]+).html /article.php?article=$1 [NC] Code (markup):
Thanks premiumscripts. Will using a rewrite have any negative effect on search engines? I keep hering that we need to use a 301 redirect etherwise the current serp results can be lost.... any clarification would be apprecisted
Well, as you can see from my code sample, it is using a 301 redirect: [R=301,L] Code (markup): So this means that google will correctly interpret that the pages have moved to a new location and it shouldn't result in a ranking drop (theoretically).