Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为url重写添加一个异常_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 为url重写添加一个异常

Php 为url重写添加一个异常,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我有以下.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 Rewrit

我有以下.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:

为此:

它还排除了在变量p末尾包含单词“edit”的URL,例如:

我想在我的.htaccess文件中添加另一个排除条件,也就是排除变量p中包含单词“admin”的URL,例如:

你们能帮我修改一下条件或者增加一个排除条件吗


非常感谢

修改您的第一个条件,如下所示:

RewriteCond %{THE_REQUEST} /index\.php\?p=(?!admin)((?![^&]*?edit)[^\s&]+) [NC]
(?!admin)
是一个否定的前瞻,它断言后面的不是
admin

参考