.Htaccess URL重写 - 清除URL不起作用

时间:2016-04-14 15:06:31

标签: .htaccess

我想重写网址,但我遇到了问题。

新网址:http://example.com/restaurants/restaurent名称

原始网址:http://example.com/restaurants-menu.php?rest=restaurent+name

我试过的代码(不工作)

RewriteEngine On
RewriteRule ^rest/([^/]*)\$ /restaurants-menu.php?rest=$1 [L]

1 个答案:

答案 0 :(得分:0)

您的正则表达式模式中的问题实际上与rest/匹配,然后是文字$

请尝试使用此规则:

RewriteRule ^restaurants/([^/]+)/?$ restaurants-menu.php?rest=$1 [L,QSA,NC]
相关问题