繁体   English   中英

.htaccess文件导致重定向循环

[英].htaccess file causing a redirect loop

我的.htaccess文件导致重定向循环,不确定为什么!

这是我当前的.htaccess文件:

DirectoryIndex index.php

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/kohana/, use /kohana/
# RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

</IfModule>

试试这个.htaccess,避免循环错误:

DirectoryIndex index.php

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^((?!index\.php).*)$ index.php/$1 [NC,L]

</IfModule>

我注意到在使用Linux Apache(不再完全确定版本)时,我的网络运行良好。

但是,使用Windows Apache / 2.4.29(Win64)时,完全相同的代码(仅包含静态html文件和htaccess的整个文件夹的复制/粘贴)不起作用。 我必须添加“ RewriteBase”标签:

RewriteBase /

我相信某些默认值已更改,并且已将其重定向到其他文件夹(其中index.html显然不存在)

暂无
暂无

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

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