我使用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>
以供將來參考,以下說明工作http://www.highermedia.com/articles/nuts_bolts/tutorial_advanced_codeigniter_installation – mv3