我有一个.htaccess,其中包含以下内容:
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(.*)/maintenance/(.*)$ [NC]
RewriteRule ^(.*).jpg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).jpeg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).gif$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).png$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule ^(.*).php$ /mysite/maintenance/maintenance.php [NC,R=302,L]
在本地主机上测试。
使用这些设置,尝试加载http://localhost/mysite/test.php时,(正确地)重定向到http://localhost/mysite/maintenance/maintenance.php时,我遇到了无限循环。
该循环似乎是由于4图像重定向(注意:维护页面在维护文件夹根目录中有一个唯一的jpg背景图像)。注释这4条重定向行即可解决该问题。
但是我看不到为什么我进入无限循环,因为/ maintenance /路径本身在RewriteCond中未从重定向中排除,以及为什么图像上的重定向会干扰此问题。
你能帮我吗 ?
您必须RewriteConds
像这样重新排序:
RewriteEngine On
RewriteRule \.jpg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule \.jpeg$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteRule \.gif$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteCond %{REQUEST_URI} !^.*/maintenance/.*$ [NC]
RewriteRule \.png$ /mysite/maintenance/transparent.png [NC,R=302,L]
RewriteCond %{REQUEST_URI} !^.*/maintenance/.*$ [NC]
RewriteRule \.php$ /mysite/maintenance/maintenance.php [NC,R=302,L]
RewriteCond
指令仅影响RewriteRule
它之后的第一个。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句