我一直拉着我的頭髮三天,我搜索了一切,一直在代碼點火器論壇上,並從頂部到底部檢查堆棧溢出。無法從CodeIgniter中的URL中刪除index.php
我想要做的就是從url中刪除index.php。我發現我的問題最近的帖子沒有回答: Post
如果我去localhost/CodeIgniter
我的主頁面顯示。如果我點擊我的鏈接,則會出現頁面不存在的錯誤。
404 Page Not Found
The page you requested was not found.
基於我已閱讀的一切,這裏是我目前的配置。
MAC OSX 10.8.3 MAMP 笨2.1.3
我的根目錄是WWW /笨/ 這裏是.htaccess文件是在笨根
#Deny from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CodeIgniter/
#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>
這裏是CodeIgniter的配置設置:我嘗試了沒有成功的uri_protocol的所有設置
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我ve已經啓用了mod_rewrite,並且AllowOverride在httpd.conf中設置爲All。
****更新 所以我刪除了MAMP和codeigniter,並從頭開始。現在使用下面的.htaccess文件,當我到localhost codeigniter文件夾不顯示。如果我嘗試瀏覽到該文件夾,則會收到以下錯誤消息。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
當我查看錯誤日誌,我有以下錯誤。
[Mon Apr 22 21:42:51 2013] [alert] [client ::1] /Users/me/Dropbox/www/codeigniter/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules
我證實我在我的phpinfo()中啓用了mod_rewrite;
如果我刪除.htaccess文件,我可以瀏覽到該文件夾並獲取主頁面,但當然鏈接不起作用。任何建議將不勝感激。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeigniter/
#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>
兩個小時沒事嗎?我非常驚訝 – Drewdin
僅用於測試目的,請備份當前的htaccess文件並將其替換爲此文件,然後查看是否可以無誤瀏覽。 –