如何从UBUNTU的codeigniter中删除index.php


How to remove index.php from codeigniter in UBUNTU

我知道这个问题已经被问了,我尝试了所有这些,但仍然无法从url中删除index.php。这是我的详细信息

Ubuntu 12.10
PHP : 5.4.6
Mod_rewrite in on
CI verson: 2.1

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

我也看了下面的链接,但没有运气…无法从基于url CI的站点中删除index.php

如何删除"index.php"In codeigniter's path

我的"/etc/apache2/sites-available/default"是这样的:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None 
        </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

感谢任何帮助!!

第一步:

添加到htaccess文件

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

步骤2:

在codeigniter config中删除index.php

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

步骤3:

允许在Apache配置(命令)中重写htaccess

sudo nano /etc/apache2/apache2.conf

并编辑文件&更改为

AllowOverride All

为WWW文件夹

步骤4:

启用apache mod rewrite (Command)

sudo a2enmod rewrite

步骤5:

重启Apache (Command)

sudo /etc/init.d/apache2 restart

In application/config/config.php change:

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

:

$config['index_page'] = '';

每次更改apache配置文件时都重新加载apache是一个好主意。

sudo /etc/init.d/apache2 reload

或:

sudo service apache2 reload

或:

sudo /etc/init.d/httpd reload

(或任何与您的平台相同的命令)

这里是我的。htaccess
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index'.php|static|robots'.txt|favicon'.ico|uploads|googlexxxxxxxx'.html|mobile.html)
RewriteRule ^(.*)$ index.php/$1 [L]

my .htaccess

RewriteEngine on
RewriteCond $1 !^(index.php)
RewriteRule ^(.*)$ index.php/$1 [L]