4

我是新的codeigniter,而重定向一个页面index.php默认情况下不加载,所以我已经尝试在htaccess文件中的下面的代码。我已经安装了PHP 5.3.10,apache服务器和postgres数据库。所以如果除了更改.htaccess和httpd.conf之外还有其他新的配置,请让我知道。我曾经看到过有关同一问题的问题,我提到了这些问题的所有内容,但仍然无法解决这个问题。请让我知道还有什么额外的事情要做。在codeigniter重定向不工作没有index.php?

.htaccess文件

<IfModule mod_rewrite.c> RewriteEngine On #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #This last condition enables access to the images and css folders, and the robots.txt file RewriteCond $1 !^(index\.php|public|images|robots\.txt|css) RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 
    RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^/(index\.php|assets/|humans\.txt) RewriteRule ^(.*)$ index.php/$1 [L] 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule .* index.php/$0 [PT,L] 

httpd.conf文件 服务器名本地主机

<Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
    Order deny,allow 
    Deny from all 
</Directory> 
+0

这可能会帮助http://stackoverflow.com/questions/20188957/removing-index-php-offical-guide-not-working-code-igniter?rq=1 – Pooshonk 2014-09-26 08:27:45

+0

重写模块是否启用? – lyhong 2014-09-26 08:52:54

+0

确保'application/config/config.php'中的'$ config ['index_page'] =';;' – 2014-09-26 09:12:57

回答

2

以下的事情,你应该做的,以避免index.php在url

  • 总是确保你有.htaccess文件。你已经有了。

  • 将内容包含在@charlie上面提出的.htaccess中。采用纳米命令

  • 编辑httpd.conf文件,包括主要的东西保持allowoveride所有

  • 首先禁用改写模式,并再次启用它然后使用以下命令重新启动的Apache2服务器。

    须藤a2dismod改写//它禁用改写模式

    须藤a2enmod重写//这使得重写模式

    须藤服务的Apache2重启//这将重新启动你的Apache

这就是你需要做的。祝一切顺利。

1

在.htaccess文件粘贴此

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
+0

@Charle先生,我试过这段代码它不工作 – 2014-09-26 10:27:36