使用htaccess将url参数重写到文件夹

时间:2021-08-03 10:51:52

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

我想从这个https://website.com/page.php?lang=2重写我的所有网站的网址到这个https://website.com/en/page

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

(隐藏.php扩展名时创建/ en /目录)

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

任何人都可以帮我这个吗?先谢谢你

1 个解决方案

#1


2  

Try it like this,

试试这样,

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

#1


2  

Try it like this,

试试这样,

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