Apache Mod重写停止在规则?

Apache Mod重写停止在规则?,apache,.htaccess,mod-rewrite,url-rewriting,friendly-url,Apache,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,我在我的.htaccess中有下面的mod rewrite,当我转到/commPortal.php时,它仍然将我路由到index2.php RewriteRule ^commportal/(.+)$ commPortal.php?data=$1 [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index2.php [QSA,L] RewriteCond %{RE

我在我的.htaccess中有下面的mod rewrite,当我转到/commPortal.php时,它仍然将我路由到index2.php

RewriteRule ^commportal/(.+)$ commPortal.php?data=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index2.php [QSA,L]

RewriteCond %{REQUEST_URI} \.php [NC]
RewriteRule ^ index2.php [QSA,L]
这似乎是由于
重写规则^commportal/(.+)$commportal.php?数据=$1[L]
然后被以下人员获取:

RewriteCond %{REQUEST_URI} \.php [NC]
RewriteRule ^ index2.php [QSA,L]

有没有办法让
RewriteCond%{REQUEST_URI}\.php[NC]
查看commPortal.php而不是/commPortal,或者如果已经有匹配的重写规则,甚至忽略它?

将上一条规则更改为:

RewriteRule^commportal/(.+)$commportal.php?数据=$1[L,QSA,NC]
重写规则^index2\.php$-[L,NC]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index2.php[L]
RewriteCond%{ENV:REDIRECT_STATUS}^$
重写规则\.php$index2.php[L,NC]
RewriteCond%{ENV:REDIRECT_STATUS}^$
只有在该规则之前没有内部重写的情况下,条件才会为true,因此执行该规则之前没有触发任何其他规则

使用包含原始请求而非重写请求的_REQUEST变量的另一个选项:

RewriteCond%{THE_REQUEST}\s/+commportal/[NC]
重写规则\.php$index2.php[L,NC]

请仅根据您展示的样品,尝试以下内容。请确保在测试URL之前清除浏览器缓存

RewriteRule ^commportal/(.+)$ commPortal.php?data=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index2.php [QSA,L]

RewriteCond %{REQUEST_URI} !commportal\.php/?$ [NC]
RewriteCond %{REQUEST_URI} \.php [NC]
RewriteRule ^ index2.php [QSA,L]