I have the following in my htaccess file, which takes a URL like: www.example.com/Page.php?id=About and turns it into www.example.com/about. The only issue is that the old URLs are not redirecting to the new URLs when I set up Redirect 301s in the htaccess (which I understand is because you're not supposed to pass parameters in basic Redirect 301s - example of basic Redirect that I've tried below).
Redirect 301 /Page.php?id=About http://www.example.com/about
The catch is that the new URLs don't necessarily just strip out the current id and replace it with a lowercase version. For example, I would also want to:
Redirect 301 /Page.php?id=Example http://www.example.com/example-page
I want to keep the current functionality of rewriting the URLs, but also want any visits to the old URLs to redirect to the new ones (i.e. to update Google index). Visiting www.example.com/Page.php?id=About at the moment still works but shows a page with no content.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+)/?$ Page.php?id=$1
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ Page.php?id=$1&tab=$2
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ Page.php?id=$1&tab=$2&tabid=$3
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…