【问题标题】:Removing index.php from Codeigniter URLs not working从 Codeigniter URL 中删除 index.php 不起作用
【发布时间】:2020-02-10 07:12:43
【问题描述】:

这个问题已经回答了好几次,但这些答案对我不起作用。我最近重新安装了 Windows 10,所以 XAMPP 安装是一个干净的安装,但它曾经在我的上一台 PC 上工作。 rewrite_module 已启用

当我转到 http://localhost 时,我的应用程序将我重定向到 http://localhost/login,但在我输入 http://localhost/index.php/login 之前它会显示 404

我的config.php

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

在codeigniter根文件夹的.htaccess文件中:

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

我尝试过的解决方案:

Answer 1

Answer 2(这给了我“找不到对象!”错误)

Answer 3

Answer 4

【问题讨论】:

    标签: php .htaccess codeigniter mod-rewrite


    【解决方案1】:

    我修改了 .htaccess 文件添加了这一行:

    RewriteBase /YOURPROJECTFOLDER/
    

    所以:

    RewriteEngine on
    RewriteBase /ShopCaseCodeigniter/
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
    

    【讨论】:

      【解决方案2】:

      更改 apache 服务器 httpd.conf 中的设置

      AllowOverride All -> AllowOverride FileInfo
      

      【讨论】:

        猜你喜欢
        • 2018-07-12
        • 1970-01-01
        • 2014-08-12
        • 2013-12-29
        • 2019-01-14
        • 2016-05-14
        • 2014-10-28
        • 2012-06-15
        • 2012-09-21
        相关资源
        最近更新 更多