Apache Modrewrite & 301 redirect- Dynamic URLs with characters
I've been trying for weeks, literally, to rename these URLs and also ensure the old one is 301 redirected to the new one:
www.example.com/?mod=11&p=215 - www.example.com/clean-url-section www.example.com/?mod=96&tab=6 - www.example.com/clean-url-section-2
Does anyone have any idea why I am having no luck, I got 500 server errors or nothing at all! Is it because of the question marks and characters? I'd be grateful for any help.
I have tried this (below) and it seems to be redir开发者_如何学编程ecting to the http:// www.example.com/new-page (this page doesn't exist, as I only want it to rename the page BUT use a 301 so that search engines continue you to value it)
RewriteCond %{query_string} mod=96&tab=6
RewriteRule (.*) http:// www. example.com/new-page? [R=301,L]
Scratching my head!
First you should do all your tests with 302 error code, and change them to 301 only when everything works. As when you have send a response with a 301 code the browser you used (or the robot which received the response) will not ask you a second time for that url. This can explain why all your tests still fail. So use 301 with caution!
Then to debug the rewrite things set RewriteLoLevel to 9 and RewriteLog to a file on a temp directory, and check what the rewrite engine does.
Last, If you have a lot of url to rewrite check for RewriteMap, can be usefull.
精彩评论