SEO 友好 URL 导致 CSS IMG 和 JS 不起作用 [英] Seo Friendly URL results in CSS IMG and JS not working

查看:33
本文介绍了SEO 友好 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 友好 URL 导致 CSS IMG 和 JS 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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