【问题标题】:Didn't remove index.php when redirection - codeigniter重定向时没有删除 index.php - codeigniter
【发布时间】:2019-11-23 07:30:23
【问题描述】:

我尝试了很多方法来删除我的项目中的 index.php。 这里的方法

这是我的路线文件

$route['default_controller'] = 'auth/login';
$route['signin'] = 'auth/login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

这是我的 htacess 文件

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]

在配置文件中

<Directory "C:/xampp2/cgi-bin">
    AllowOverride All
    Options None
    Require all granted
</Directory>

仍然需要 index.php。我该怎么做才能删除它?

【问题讨论】:

    标签: codeigniter redirect


    【解决方案1】:

    在您的配置中,

    $config['index_page'] = 'index.php';
    

    替换为:

    $config['index_page'] = '';
    

    【讨论】:

    • LoadModule setenvif_module modules/mod_setenvif.so 这个启用
    • 找到文本#LoadModule rewrite_module modules/mod_rewrite.so 并删除#然后保存,重启你的apache
    • 实际上进展顺利,但在文件 .htaccess 上试试这个: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.* )$ index.php/$1 [L]
    • 请查看link
    【解决方案2】:

    在 .htaccess 文件中我创建了这个

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

    它对我有用。

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 2018-03-31
      • 1970-01-01
      • 2016-07-02
      • 2015-03-19
      • 2013-05-20
      • 1970-01-01
      • 2012-04-03
      • 2011-07-09
      相关资源
      最近更新 更多