Forum Moderators: phranque
e.g.
old: index.php?q=123 to new: /abcd/
old: index.php?q=124 to new: /efgz/
etc.
I've tried the following but its retaining the query string:
RewriteCond %{query_STRING} ^q=123$
RewriteRule ^index\.php$ /abcd/ [R=301,L]
Is there a way to do this purely with htaccess?
RewriteRule ^index\.php$ /abcd/? [R=301,L]
will lose the query string in the redirect.
Additionally, you should add the domain to the redirect so that you don't allow indexing at both www and non-www. You might have a separate rule for that already, but if you fail to add the domain here as well, then some requests will see a double redirect - and that is bad.
RewriteRule ^index\.php$ http://www.domain.com/abcd/? [R=301,L]
Finally, the root page of the site is the most important page of the site. It is very bad form to serve a redirect to a deep internal URL within the site.
Consider using a rewrite to pull content from a deep filepath while continuing to show the root URL. URLs and files are two different things.