我试图用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