MarcusV
MarcusV

Reputation: 353

Rewrite url parameter to folder with htaccess

i would like to rewrite all my website's urls from this https://website.com/page.php?lang=2 to this https://website.com/en/page

(creating /en/ directory while hiding .php extension)

Can anyone help me with this one? Thank you in advance

Upvotes: 1

Views: 549

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try it like this,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/([\w-]+)$ $1.php?lang=2 [QSA,L]

Upvotes: 2

Related Questions