Deepak Dholiyan Deepak Dholiyan - 9 days ago 5
PHP Question

htaccess redirection without base name

I am handling some urls with the htaccess like below

B)https://www.example.com/online/development/id


Rules:

RewriteRule ^online/(.*)/(.*)$ filename.php?key=$2 [L]


But Now I want to use some urls like below:-

https://www.example.com/development/id


How Can I do this?

Answer

You can use this rule-

RewriteRule ^([\w-]+)/([\w-]+)$ filename.php?key=$2 [QSA,L]