我一直在网上想知道如何使用 htacces(真的很难学)。当我潜伏在互联网上时,我发现了这个:http://www.generateit.net/mod-rewrite/
好吧,我插入了我的 url(在本地主机上工作):empresa.com/index.php?p=sub_artigo&id=1&cat=Mercearia
它给了我这个(默认所有选项):http://empresa.com/sub_artigo/5/Mercearia.html
.htacces 代码是这样的:RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$/index。 php?p=$1&id=$2&cat=$3 [L]
当我在 php 中生成 url 时,我会这样做
<a href=\"sub_artigo/".$response2['ID_sub_artigo']."/".$response2['url'].".html\">$response2[nome_sub_artigo]</a>
然后,当我单击该按钮时,它看起来像只有 html。 示例:http://s14.postimg.org/wr137fx4x/htacces_error.jpg
知道发生了什么吗?
最佳答案
看起来您正在为您的 Assets (图像、javascript、css)使用相对链接。
这意味着当您从新的 url 中查找 css/my_stylesheet.css
时,浏览器将请求一个类似于 http://empresa.com/sub_artigo/5/的 url css/my_stylesheet.css
.
最简单的解决方案是始终为您的资源使用绝对 URL,例如 /css/my_stylesheet.css
等。
关于php - .htaccess 只出现 html 而没有 CSS 或 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17702084/