【问题标题】:Removing index.php of codeigniter on local在本地删除 codeigniter 的 index.php
【发布时间】:2013-10-19 09:50:21
【问题描述】:

我正在尝试删除我的本地主机中的 index.php,但它似乎不起作用,它在 http://localhost/testing 上。

我将 .htacces 放在 htdocs 下的“测试”目录中。

LoadModule rewrite_module modules/mod_rewrite.so 在 Apache/conf 也已经取消选中。

这是我的 .htaccess:

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

这是我的配置:

$config['base_url']    = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

当我访问登录控制器时,它没有找到。

找不到

在此服务器上找不到请求的 URL /testing/login。

我真的不知道接下来该尝试什么。任何帮助将不胜感激。

【问题讨论】:

  • 还有其他设置吗?

标签: php apache codeigniter mod-rewrite


【解决方案1】:

试试这个:-

Config.php :-

$config['base_url'] = 'http://localhost/testing/';

$config['index_page'] = '';

.htaccess

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

【讨论】:

    【解决方案2】:

    你的htaccess 应该是这样的

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

    没有必要附加/testing/,因为RewriteBase 已经处理好了。

    【讨论】:

    • 是否启用了 mod_rewrite?将标志更改为[R,L] 以查看浏览器是否被重定向。
    【解决方案3】:

    基本上 index.php 包含在所有 URL 中:

    我们可以通过简单的规则使用 .htaccess 删除它。以下是此类文件的示例,使用“否定”方法重定向所有内容,

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

    现在重启你的服务器并检查

    【讨论】:

      【解决方案4】:

      省略RewriteBase 中的尾部斜杠:

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

      $config['base_url'] 应该是http://localhost/testing/

      $config['index_page'] 应该为空。

      【讨论】:

        【解决方案5】:

        在 .htaccess 文件中试试这个:

        RewriteEngine on
        RewriteCond $1 !^(index\.php|robots\.txt|resources)
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?$1 [L]
        ErrorDocument 404 /mainpage
        

        你的配置文件没问题

        区别在于“?”在 index.php 之后

        【讨论】:

          【解决方案6】:

          您可能还想尝试更改 ./application/config/config.php 中 $config[‘uri_protocol’] 的值。有时 CodeIgniter 会出错。将其更改为 PATH_INFO 可能会起作用。

          【讨论】:

            猜你喜欢
            • 2011-07-09
            • 1970-01-01
            • 2012-10-30
            • 2016-07-26
            • 2019-04-06
            • 2019-08-03
            • 2017-04-04
            • 1970-01-01
            • 2013-04-19
            相关资源
            最近更新 更多