如何从笨在Ubuntu中删除的index.php [复制](How to remove index.

2019-09-03 06:05发布

这个问题已经在这里有一个答案:

  • 如何删除“的index.php”在CodeIgniter的路径 26回答

我知道这个问题正在被问了,我尝试了所有仍然无法从URL中移除的index.php,但那些。 这里是我的个人资料

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

.htacess样子:

RewriteEngine On
RewriteBase /projectname

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

我也看看下面的链接,但没有运气.. 无法从URL CI基础的网站删除的index.php

如何删除“的index.php”在CodeIgniter的路径

我在“/ etc / apache2的/网站可用/ 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>

任何帮助表示赞赏!

Answer 1:

application/config/config.php的变化:

$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]


Answer 2:

步骤1 :

在htaccess文件添加此

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

第2步 :

删除的index.php在笨配置

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

第3步:

允许在Apache的配置覆盖htaccess的(命令)

sudo nano /etc/apache2/apache2.conf

和编辑文件及变化

AllowOverride All

对于WWW文件夹

第4步 :

启用阿帕奇国防部重写(命令)

sudo a2enmod rewrite

第5步:

重启Apache(命令)

sudo /etc/init.d/apache2 restart


Answer 3:

我的.htaccess

RewriteEngine on

RewriteCond $1 !^(index.php)

RewriteRule ^(.*)$ index.php/$1 [L]


文章来源: How to remove index.php from codeigniter in UBUNTU [duplicate]