2010-10-19 97 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