为什么我不能从 codeigniter URL 中删除 index.php

Why can I not remove index.php from codeigniter URL

我新安装了 Kubuntu 15.10,其中包含我网站上的旧(有效)代码。 不知何故,我无法摆脱 URL 中的 index.php。 我厌倦了几十个建议,但似乎没有任何效果。 我目前的状态是这样的:

Apache 2 mod_rewrite 在: printout of php_info()

Apache2 配置为:

<Directory /var/www>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

我的 .htaccess 位于应用程序文件夹下:

<IfModule mod_rewrite.c>  
    RewriteEngine on
    RewriteBase /
    # Hide the application and system directories by redirecting the request to index.php
    RewriteRule ^(application|system|\.svn) index.php/ [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/ [QSA,L]
    RewriteRule ^(.*)$ index.php/ [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php
</IfModule>

我在这里错过了什么?我正在失去信心...:-P

在 application/.htaccess 中尝试,index.php 将存在于 url 但在脚本中它将被忽略。

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/[=10=] [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/[=10=] [PT]

第 1 步:在您的 .htaccess 中替换所有其他代码..试试这个:

RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/[=10=] [PT,L]

第 2 步:将您的 .htaccess 应用程序文件夹 移动到 index.php位于。

第 3 步:改变您的 config.php

发件人:

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

$config['index_page'] = '';