【问题标题】:Remove index.php in CodeIgniter_2.1.4删除 CodeIgniter_2.1.4 中的 index.php
【发布时间】:2014-04-09 03:17:38
【问题描述】:

我是Codeigniter 的新手,正在尝试配置Codeigniter

但我无法从 url 中删除 index.php..

我按照用户指南中给出的数据更改了.htaccess 文件..

.htacess 文件包含

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

还修改了配置文件

$config['index_page'] = '';

当我尝试使用以下网址时,结果

在此服务器上找不到请求的 URL /codeigniter/pages/view。

http://localhost/codeigniter/pages/view

但我尝试在 url 中使用 index.php..页面正常显示..

http://localhost/codeigniter/index.php/pages/view

是 .htaccess 的问题还是我必须更改一些其他文件..

如何解决这个问题?

任何建议,可接受。

更新

我使用的是 ubuntu 3.10

我使用以下命令启用模块重写

 sudo a2enmod rewrite

结果如下

  Module rewrite already enabled

我更改了权限

  /etc/apache2/sites-enabled/000-default

作为

ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

更改此文件后也没有运气..

【问题讨论】:

    标签: php .htaccess codeigniter ubuntu


    【解决方案1】:

    在您的httpd.conf(在 Windows 上)

    取消注释下面的行

    LoadModule rewrite_module modules/mod_rewrite.so

    在 ubuntu 中 使用sudo a2enmod rewrite 启用mod_rewrite

    修改后重启apache

    【讨论】:

    【解决方案2】:

    进行此更改

    在 config.php 中

    $config['index_page'] = '';
    

    IN 根 .htaccess 文件

    DirectoryIndex index.php
    
    RewriteEngine On
    
    RewriteCond $1 !^(index\.php|themes|utils|robots\.txt|favicon\.ico)
    
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^(.*)$ ./index.php?/$1 [L]
    

    【讨论】:

    【解决方案3】:

    没有人提到更改设置。在您的 httpd 配置文件中找到并像这样更改它

    <Directory "/var/www/html">  # your DocumentRoot setting
        Options FollowSymLinks
        AllowOverride All  # default is None
        Order allow,deny
        Allow from all
    </Directory>
    

    【讨论】:

      【解决方案4】:

      我终于找到了我的问题的答案。因为下面的 .htaccess 解决了我的问题..

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

      谢谢大家..

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-06-22
        • 1970-01-01
        • 1970-01-01
        • 2012-10-30
        • 2015-03-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多