我試圖用CodeIgniter這些天。.htaccess隱藏index.php與相關鏈接問題
默認情況下,它有這樣的
http://www.example.com/index.php/home
home
在URI的index.php文件是控制器
內部的功能,但我不希望index.php
所以我創建.htaccess文件:
Allow from all
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|img|robots\.txt|script|css)
RewriteRule ^(.*)$ index.php/$1 [L]
基本上它會自動添加「index.php」,除非cond匹配。
但是這裏的東西:
對於URI是這樣的:http://www.example.com/home
一切工作正常。
對於這樣的URI:http://www.example.com/home/
然後,我的網頁中的相關鏈接變得瘋狂。
例如: css/common.css
被重定向到index.php/home/css/common.css
導致未找到css文件。
日誌是這樣的:
strip per-dir prefix: [dir to my site]/home/css/common.css -> home/css/common.css
applying pattern '^(.*)$' to uri 'home/css/common.css'
rewrite 'home/css/common.css' -> 'index.php/home/css/common.css'
add per-dir prefix: index.php/home/css/common.css -> [dir to my site]/index.php/home/css/common.css
trying to replace prefix [dir to my site]/ with/
internal redirect with /index.php/home/css/common.css [INTERNAL REDIRECT]
add path info postfix: [dir to my site]/index.php -> [dir to my site]/index.php/home/css/common.css
strip per-dir prefix: [dir to my site]/index.php/home/css/common.css -> index.php/home/css/common.css
applying pattern '^(.*)$' to uri 'index.php/home/css/common.css'
pass through [dir to my site]/index.php
我該如何解決這個問題?
+1添加日誌! – Ansari 2012-07-14 00:44:25