Apache .htaccess用于停止执行的重写规则

Apache .htaccess用于停止执行的重写规则,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,大多数my htaccess规则将未签名用户重定向到index.html 但当我将它们重定向到index.html时,所有这些规则也会针对该页面重新运行。我需要为访问索引文件的用户运行一组最小的规则 很明显,[L]会停止htaccess规则的运行 解决这个问题最好的办法是什么?这是一个正确的方法还是你有更好的建议 RewriteCond %{REQUEST_URI} index\.html RewriteRule ^(.*)$ index.html [L] 我的完全访问权限: <IfMo

大多数my htaccess规则将未签名用户重定向到
index.html

但当我将它们重定向到
index.html
时,所有这些规则也会针对该页面重新运行。我需要为访问索引文件的用户运行一组最小的规则

很明显,
[L]
会停止htaccess规则的运行

解决这个问题最好的办法是什么?这是一个正确的方法还是你有更好的建议

RewriteCond %{REQUEST_URI} index\.html
RewriteRule ^(.*)$ index.html [L]
我的完全访问权限:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} (\/onefolder|\/secondfolder) [NC]
    RewriteCond %{REMOTE_ADDR} !111\.22\.33\.44 [NC]
    RewriteCond %{REQUEST_URI} !(index\.html) [NC]
    RewriteRule ^(.*)$ index.html [F]

    RewriteCond %{HTTP_USER_AGENT} oneagent|otheragent [NC]
    RewriteCond %{REQUEST_URI} !(index\.html) [NC]
    RewriteRule ^(.*)$ index.html? [R=301,L]

    RewriteCond %{HTTP_USER_AGENT} betteragent|otherbetterganet [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(index\.html) [NC]
    RewriteRule ^(.*)$ index.html? [R=301,L]

    RewriteCond %{HTTP_COOKIE} !username [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(\/importantone|\/somefolder|index\.html) [NC]
    RewriteRule ^(.*)$ index.html [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

重新启动发动机
重写条件%{HTTP_HOST}^www\.(.*)$[NC]
重写规则^(.*)$http://%1/$1[R=301,L]
重写cond%{REQUEST\u URI}(\/onefolder\124;\/secondfolder)[NC]
重写cond%{REMOTE_ADDR}!111\.22\.33\.44[北卡罗来纳州]
重写cond%{REQUEST_URI}!(index\.html)[NC]
重写规则^(.*)$index.html[F]
RewriteCond%{HTTP_USER_AGENT}oneagent | otheragent[NC]
重写cond%{REQUEST_URI}!(index\.html)[NC]
重写规则^(.*)$index.html?[R=301,L]
RewriteCond%{HTTP_USER_AGENT}betteragent | otherbetterganet[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_URI}!(index\.html)[NC]
重写规则^(.*)$index.html?[R=301,L]
重写cond%{HTTP_COOKIE}!用户名[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_URI}!(\/importantone |\/somefolder | index\.html)[NC]
重写规则^(.*)$index.html[L]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$index.php[QSA,L]

您可以做一些事情。如果您想简单地停止对
index.html
的重写,您可以在规则的最顶端执行与您所做的类似(但更简单)的操作:

RewriteRule ^/?index.html$ - [L]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
-
只是简单地“通过”,本质上使重写停止在那里

或者,您可以通过将以下内容添加到规则顶部来完全防止循环:

RewriteRule ^/?index.html$ - [L]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
执行类似的操作,但检查是否存在任何类型的内部重定向