url 重写 deosnt 访问我的 css 和图像?为什么
我的 url 有这个重写规则,它似乎无法访问 css 和图像,为什么? :))
原始网址其工作:
http://www.example.co.uk/viewprofile.php?user=muna
重写的网址,此 deosnt 工作:
http://www.example.co.uk/user/muna
htaccess 代码:
RewriteEngine On
RewriteRule ^user/([^/]*)$ /viewprofile.php?user=$1 [L]
我的 css 文件存储在 /css 文件夹中,图像存储在 /images 文件夹中
i have this rewrite rule for my urls, it deosnt seem to acess the css and images, why? :))
orginal url its working:
http://www.example.co.uk/viewprofile.php?user=muna
rewrited url, this deosnt work:
http://www.example.co.uk/user/muna
htaccess code:
RewriteEngine On
RewriteRule ^user/([^/]*)$ /viewprofile.php?user=$1 [L]
my css files are stored in /css folder and images in the /images folder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,我找到了解决方案,我将回答这个问题只是为了将来为其他 stackoverflowers 提供参考,基本上,当您对任何 url 进行重写时,只需确保您以正确的方式链接到 javascript、css 或图像,例如:
如果在之前你有:
然后更改为:
在 css 文件夹名称之前引用额外的
/
。谢谢希望有帮助sorry guys, i found the solution, im gonna answer this question just for future reference for other stackoverflowers, basically when you do a rewrite on any url just make sure when your linking to javascripts, css or images the right way for example:
if before you had:
then change to this:
quote the extra
/
before css folder name. thanks hope it helps或者你可以添加一些规则,然后你可能不需要更改html代码。
RewriteRule ^user/css/(.*)$ /css/$1 [L]
or you can add some rules, and then you may don't need change the html code.
RewriteRule ^user/css/(.*)$ /css/$1 [L]