使用类似字符串编写.htaccess重写规则

6ljaweal  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(133)

我正在我的.htaccess文件中编写规则来配置显示的URL。
在我的网站我有两个页面。例如。page.php和page_edit. php。
我的.htaccess文件我制定了以下规则:

RewriteRule ^page page.php [NC,L]
RewriteRule ^page/create page_edit.php?editID=1 [NC,L]

然而,第二条规则永远不会被捕获,页面总是被定向到page.php(第一条规则)。我猜这是因为它将第一条规则的字符串('page ')作为子字符串。
我怎样才能绕过这个问题呢?

xbp102n0

xbp102n01#

您可以更改规则顺序,在top中更具体

RewriteRule ^page/create page_edit.php?editID=1 [NC,L]
RewriteRule ^page page.php [NC,L]

相关问题