【问题标题】:Cannot remove index.php using htaccess无法使用 htaccess 删除 index.php
【发布时间】:2012-09-08 13:18:49
【问题描述】:

当我尝试删除 index.php 和访问控制器:mysite.com/admin 我不断收到内部服务器错误。 我不知道为什么它不起作用。

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /code/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ index.php?/$1 [L]

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

网站配置

<Directory /home/mysite.com/public_html/>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory> 

Apache 错误日志

[Sat Sep 08 15:24:30 2012] [error] [client 176.106.162.240] 
Request exceeded the limit of 10 internal redirects 
due to probable configuration error. Use 'LimitInternalRecursion' 
to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

【问题讨论】:

  • 您是否查看了服务器错误日志以确切了解导致 500 的问题是什么?你应该自己做一些基本的调试,总是从查看日志开始,而不是让我们猜测问题。

标签: php apache .htaccess codeigniter


【解决方案1】:

更改 .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /code/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ index.php?/$1 [L]

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

进入这个:

RewriteEngine On

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

我不相信你还需要别的东西。

【讨论】:

  • 嘿,我有 Index.php 而不是 index.php,你能帮帮我吗?
【解决方案2】:

没有仔细看,我发现RewriteBase /code/有问题

试试RewriteBase /

【讨论】:

    【解决方案3】:
    You just need to create .htaccess file in project folder and write:
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all other URLs to index.php/URL 
    RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 
    
    </IfModule>
    <IfModule !mod_rewrite.c>
       #ErrorDocument 404 index.php
    </IfModule>
    
     #And You don't need to define in base_url in config file:
    
     $config['base_url'] = '';// blank it.
    
     I hope it will work perfectly ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 1970-01-01
      • 2014-02-19
      • 2021-10-02
      • 2015-01-20
      • 2023-03-07
      相关资源
      最近更新 更多