如何修复使用htaccess后的资源文件路径


How to fix resource file path after using htaccess

浏览器显示:

http://example.com/first/second

遇到一个相对URL,如:

<img src="site/images/photo.png">

它将相对URL转换为(分别):

http://example.com/first/second/site/images/photo.png

那么解决方案是什么呢

尝试将代码添加到RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

您还可以将以下内容添加到<head>中,这也可以工作。

<base href="http://www.example.com/" />