我的大多数 htaccess 规则将未签名的用户重定向到index.html
.
但是当我将它们重定向到 时index.html
,所有这些规则也会针对该页面重新运行。我需要为访问索引文件的用户运行最少的规则集。
很明显,这会[L]
阻止 htaccess 规则的运行。
解决这个问题的更好方法是什么?这是一种正确的方法还是您有更好的建议?
RewriteCond %{REQUEST_URI} index\.html
RewriteRule ^(.*)$ index.html [L]
我的完整 htaccess:
<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>