.htaccess文件导致过多的重定向错误

时间:2017-03-29 11:25:56

标签: php codeigniter

我的.htaccess文件中有以下重定向规则:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule !^(.*)$ /index.php/$1 [L]

这导致我网站上的重定向错误太多。此外,此问题仅在我的本地计算机上发生,并且该站点在远程服务器上运行正常。

请帮忙!

2 个答案:

答案 0 :(得分:0)

RewriteRule !^(.*)$ index.php?/$1 [L]

尝试在index.php之后添加问号,并查看Michael Berkowski的答案。

答案 1 :(得分:0)

请按以下步骤操作:

  1. 转到application / config / config.php并将$config['index_page'] = 'index.php';更改为$config['index_page'] = ''; // remove index.php

  2. 在同一文件application / config / config.php中添加基本网址:$config['base_url'] = 'http://localhost/yourapp';

  3. 检查您的apache服务器是否已启用重写模块。

  4. 在根目录中添加.htaccess文件

    RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]