繁体   English   中英

.htaccess-此网页具有重定向循环

[英].htaccess - This webpage has a redirect loop

我正在清理URL,一切看起来都很好,但是每当我尝试访问任何目录(例如图像等)时,chrome都会显示“此网页具有重定向循环”。 但是我想保护public_html内的目录。

.htaccess文件位于public_html内部

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
</ifModule>

我想保护图像,css和javascript目录,但希望允许访问admin目录。

预先感谢。

更改规则的顺序并更改结尾的斜杠删除规则:

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ $1 [R=301,L]

# block all directories except admin/
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule !^admin(/|$) - [NC,F]

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

您可以使用此删除所有代码,并使用此一个选项索引允许和不允许成为索引目录,例如

这可以解决问题。

选项全部-索引

要么

IndexIgnore *有关更多信息,请检查以下链接http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-prevent-htaccess-directory-listing/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM