I want to redirect a request look like
mydomain.com/abc/def
to
mydomain.com/abc/index.php?q=def
where abc
is a fixed directory name and def
can be any string.
How can I do this using .htaccess
?
Webmasters Stack Exchange is a question and answer site for webmasters. It only takes a minute to sign up.
Sign up to join this communityIn .htaccess
put:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} !id=
RewriteRule ^abc/(.+) /abc/index.php?id=$1 [NC,L]
Note that I included a check for the presence of the id
query string parameter to prevent the url http://mysite.com/abc/index.php?id=def
from being rewritten.
mydomain.com/abc/def
to remain in the address bar?