【问题标题】:Remove Index.php from URL of sub domain从子域的 URL 中删除 Index.php
【发布时间】:2017-09-20 19:11:08
【问题描述】:

你好朋友,我有像exam.example.com这样的子域,我需要从我的url中删除index.php,比如exam.example.com/index.php/controller/func_name

我在 config.php 中替换了以下内容

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

替换

$config['index_page'] = '';

并在我的项目中创建 .htaccess 文件并编写以下代码 -

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

【问题讨论】:

标签: .htaccess codeigniter


【解决方案1】:

我还将我的一个 CodeIgniter 项目作为子域托管,就像您的一样。我没有像你这样的问题。

我还替换了 config.php 中的以下内容 $config['index_page'] = 'index.php'; 替换为 $config['index_page'] = '';

这是我的 .htaccess 文件

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

如果这个 .htaccess 文件对您不起作用,您需要允许在 Apache 配置中覆盖 htaccess。 有关 .htaccess 覆盖的更多信息,请访问 Codeigniter - getting 404 Not Found error

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-14
    • 2014-10-28
    相关资源
    最近更新 更多