【问题标题】:codeigniter index.php hide from urlcodeigniter index.php 从 url 隐藏
【发布时间】:2015-12-19 11:28:45
【问题描述】:

所有这些步骤都有效??我尝试过但无法在我的 ubuntu 机器上工作

1.在 application/config.php 文件中进行以下更改

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

2.使用以下代码在根目录中制作 .htacces 文件

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

3.启用重写模式(如果您的重写模式未启用)

我。首先,使用以下命令启动它:

a2enmod 重写

二。编辑文件 /etc/apache2/sites-enabled/000-default

将 All AllowOverride None 更改为 AllowOverride All。

三。使用以下命令重新启动服务器:

sudo /etc/init.d/apache2 restart

【问题讨论】:

标签: apache .htaccess codeigniter ubuntu mod-rewrite


【解决方案1】:

我之前已按照这些步骤进行操作。 Remove index from CI

【讨论】:

    【解决方案2】:

    有些时间步骤 3 不起作用,检查 httpd.conf 文件是否存在于 apache 文件夹中,然后您必须检查您的代码库文件夹路径 允许覆盖所有

    但在此之前检查您的文件夹权限,以及 htacces 文件是否可执行。

    【讨论】:

      【解决方案3】:

      config/config.php 中,更改此项

      $config['base_url'] = '';
      $config['index_page'] = '';
      $config['uri_protocol'] = 'AUTO';
      

      并在.htaccess 文件中(放置在应用程序文件夹之外)

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

      【讨论】:

        猜你喜欢
        • 2011-02-15
        • 1970-01-01
        • 1970-01-01
        • 2015-01-21
        • 1970-01-01
        • 2016-09-22
        • 2010-11-20
        • 1970-01-01
        • 2013-07-07
        相关资源
        最近更新 更多