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

相關問題