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

时间:2015-10-24 16:10:57

标签: codeigniter url ubuntu indexing apache2

我从我的网站上安装了新的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/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

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

我在这里缺少什么?我失去信心...... :-P

2 个答案:

答案 0 :(得分:0)

在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/$0 [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/$0 [PT]

答案 1 :(得分:0)

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

config.php

第2步:将 .htaccess 应用程序文件夹移至 index.php 所在的位置。

第3步:更改$config['index_page'] = 'index.php';

自:

$config['index_page'] = '';

/*header*/
<div id="headerDiv">
    /*.......*/
</div>

/*body*/
<div class="calendar">
    /*.......*/
</div>