通常我訪問一個頁面是這樣的:http://localhost/codeigniter/index.php/auth/login
但是我希望能夠訪問該頁面是這樣的:http://localhost/codeigniter/auth/login
如何從我的鏈接中刪除「index.php」?
我沒有任何有關http.conf
和.htaccess
配置。
我在codeigniter/application/config/config.php
我的http.conf文件中設置$config['index_page'] = '';
是除uncommentnig其默認「LoadModule rewrite_module modules/mod_rewrite.so
」
我考察提出了許多.htaccess文件,但我不明白的重寫規則背後的邏輯。
這裏是我最成功的.htaccess
內容。它位於/www/CodeIgniter/
。
(由最成功的我的意思是,這是唯一一個不通過服務器對由笨創建404錯誤)
RewriteOptions Inherit
Options -Indexes
Options +FollowSymLinks
RewriteBase /CodeIgniter/
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# activate URL rewriting
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(images|assets|uploads|captcha)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt)
# but rewrite everything else
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.
ErrorDocument 404 index.php
</IfModule>
我討厭請求直接的解決方案然而不幸的是,這是我的最後一招:/ 你能給我一個正確的解決方案來解決我的問題嗎?
嘗試更換'RewriteBase /笨/ '這個'RewriteBase /' – manix
'.htaccess'文件看起來或多或少是正確的。如果鏈接不通過,可能是CodeIgniter問題。在'RewriteBase'之後的位,就像manix所說的那樣,是你的域到你的.htaccess的主目錄之後的路徑,你聲明的是'/ CodeIgniter /',所以應該是正確的。 – Orbling
是否在您的服務器上啓用了rewritemodule?檢查您的.htaccess文件是否正常工作。[link](http://jappler.com/blog/archive/2008/10/22/how-to-test-htaccess-files) –