【发布时间】:2014-09-11 13:23:55
【问题描述】:
我有以下 .htaccess 文件内容:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?p=((?![^&]*?edit)[^\s&]+) [NC]
RewriteCond %{THE_REQUEST} /index\.php\?p=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?p=$1 [L,QSA]
这会重写如下 URL: http://domain.com/index.php?p=Contacts&ms=m5&l=en&
进入这个: http://domain.com/Contacts
它还排除了在变量 p 末尾包含单词“edit”的 URL,例如: http://domain.com/index.php?p=Contactsedit&l=en
我想在我的 .htaccess 文件中再添加一个排除条件,也就是排除变量 p 中包含单词“admin”的 url,例如: http://domain.com/index.php?p=admin
你们能帮我修改条件或添加排除条件吗?
非常感谢
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite