如何在.htaccess重写中修复图像路径?

时间:2012-10-24 00:36:31

标签: php apache .htaccess

我做了如下重写规则:

RewriteCond %{REQUEST_URI} !^(/index.php)|(index.php)|\.(gif|jpe?g|png)|(/public/)|(/forum/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?qs=$1

当有人说www.example.com/a/b时,一切都很好,除了图像。

图像在我的脚本中作为相对路径链接,它们位于www.example.com/images,但服务器正在尝试从www.example.com/a/b/images加载图像。

有没有办法通过编辑我的RewriteRule来解决这个问题?这将是一个最佳解决方案,因为我很难更改脚本中的所有图像路径。

1 个答案:

答案 0 :(得分:0)

试试这个,第一行:

RewriteCond %{REQUEST_URI} !^(/index.php)|(/images)|(images)|(/forum/)