2010-10-19 66 views
0

我在子文件夾http://example.com/some/other/sub/folder/中有應用程序。 而.htaccess文件:在.htaccess中重寫靜態文件

RewriteEngine on  
    RewriteBase /some/other/sub/folder 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L] 

模板文件包含絕對URL的圖像,js和css文件:/images/header.png/js/common.js

我的問題是使用絕對路徑靜態文件無法訪問。

Thx。

回答

0

原因是,通過引用絕對URL路徑/images/header.png您實際上引用/images/header.png而不是/some/other/sub/folder/images/header.png

使用與/some/other/sub/folder/一起使用的相對URL路徑作爲基本路徑。或者使用絕對URL路徑,例如/some/other/sub/folder/images/header.png,這些路徑獨立於實際的基本路徑。

+0

非常感謝,但我們找到的最簡單的解決方案就是將應用移動到服務器的根目錄;) – 2010-10-28 07:56:01