2013-08-21 50 views
1

我使用CodeIgniter,我試圖從url中刪除index.php。我在Apache中啓用了mod_rewrite,我在CI配置文件中將索引設置爲空字符串,並使用頁面底部的.htaccess文件。我認爲問題的一部分可能是我的應用程序和系統文件夾不在我的文檔根目錄中。我的本地服務器文件夾結構如下:Codeignitier mod_rewrite和父文件夾

mysite.dev/ 
-public_html (server root) 
-application 
-system 
-.htaccess 

我做到了,那是因爲我讀,這將是具有的public_html文件夾以外的應用程序和系統額外的安全性。但重寫規則不起作用,我懷疑它與此有關。我相對比較新,所以我非常感謝任何幫助!

我htaccess文件:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#’system’ can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#When your application folder isn’t in the system folder 
#This snippet prevents user access to the application folder 
#Submitted by: Fabdrol 
#Rename ’application’ to your applications folder name. 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#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 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don’t have mod_rewrite installed, all 404′s 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule> 
+0

以供將來參考,以下說明工作http://www.highermedia.com/articles/nuts_bolts/tutorial_advanced_codeigniter_installation – mv3

回答

0

,因爲它是爲我工作我已經用我的.htaccess文件的代碼。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 
+0

它仍然沒有工作,如果我嘗試訪問本地主機的/ home我得到一個404錯誤,但本地主機/index.php/home工作。我試過你的htaccess,我重置Apache但沒有運氣 – mv3