Seo Friendly URL导致CSS IMG和JS无法正常工作 [英] Seo Friendly URL results in CSS IMG and JS not working

查看:85
本文介绍了Seo Friendly URL导致CSS IMG和JS无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的URL设置为SEO友好URL.我尝试通过重写规则来编辑.htaccess文件

I want to make my URL as SEO Friendly URL. I tried editing .htaccess file by rewriting rule

RewriteRule ^swift-details/([0-9]+)/([0-9a-zA-Z_-]+)$ swift-details.php?id=$1 [NC,L]
RewriteRule ^swift-details/(css|js|img)/(.*)?$ /$1/$2 [L,QSA,R=301]

它正在路由正确的URL,但是在该页面中CSS JS和图像无法正常工作.

It's routing the correct URL but in that page CSS JS and images are not working.

示例网址:

http://www.example.com/swift-details/2/abblinbb

推荐答案

您不需要第二个重写规则.您的CSS/JS路径都相对于您当前的位置.

You dont need the second rewrite rule. Your CSS/JS paths are all 'relative' to your current location.

您的CSS存在于此处: /css/normalize.css

Your CSS exists here: /css/normalize.css

您的页面在这里查看: /swift-details/2/abblinbb/css/normalize.css

Your page is looking here: /swift-details/2/abblinbb/css/normalize.css

您所需要做的就是在CSS/JS路径之前加上正斜杠".

All you need is 'forward-slashes' before your CSS/JS paths.

这篇关于Seo Friendly URL导致CSS IMG和JS无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆