Mobile app version of vmapp.org
Login or Join
Odierno851

: Htaccess URL rewriting 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

@Odierno851

Posted in: #Htaccess

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Odierno851

1 Comments

Sorted by latest first Latest Oldest Best

 

@Mendez628

In .htaccess put:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{QUERY_STRING} !id=
RewriteRule ^abc/(.+) /abc/index.php?id= [NC,L]


Note that I included a check for the presence of the id query string parameter to prevent the url mysite.com/abc/index.php?id=def from being rewritten.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme