我的网站上有一个重写规则。它转换此链接:
http://www.qblza.com.br/anuncio_detalhes.php?ida=232&title=samsung-duos-camera-2-mp-redes-sociais-2-chips-bluetooth.html
进入这个:
http://www.qblza.com.br/232/samsung-duos-camera-2-mp-redes-sociais-2-chips-bluetooth.html
这是我使用的重写规则:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)'.html$ /anuncio_detalhes.php?ida=$1&title=$2 [L]
问题是当用户点击重写网址时,该网站不会加载任何 css 和图像......它只是加载文本...我不知道为什么会这样。
任何帮助将不胜感激!
在你的样式表、图像上,如果你有 JavaScript 源代码。在位置前键入"/"。
图像:
<img src="/file/to/path/image.jpg" />
样式表:
<link ref="stylesheet" href="/file/to/path/style.css" />
Javascript:
<script src="/file/to/path/javascript.js" />
问题是你对静态资源使用了相对路径。因此,当加载重写 url 时,浏览器会在脑海中看到以下内容:
<link id="menu-color" type="text/css" rel="stylesheet" href="css/menu-gray.css">
并尝试加载
http://www.qblza.com.br/232/samsung-duos-camera-2-mp-redes-sociais-2-chips-bluetooth.html/css/menu-gray.css
解决方案 1:使用绝对路径加载静态资源:
<link rel="stylesheet" type="text/css" href="/css/menu-gray.css" />
因此,您的浏览器将明确遵循域根目录的路径
解决方案 2:使用基本标记
<base href="http://your-domain.com" />
有了这个,您可以告诉浏览器在跟踪路径(以及图像等)时使用哪个根
如果没有看到html,我会说最有可能的问题是图像和css的url。当您像您一样重写网址时,您需要使用绝对网址(相对于站点根目录)。