Seo Friendly URL results in CSS IMG and JS not working

后端 未结 2 851
别那么骄傲
别那么骄傲 2020-11-21 15:30

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_-]+)$         


        
相关标签:
2条回答
  • 2020-11-21 16:07

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

    Your CSS exists here: /css/normalize.css

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

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

    0 讨论(0)
  • 2020-11-21 16:16

    This is because your relative URIs have their base changed. Originally, the base is / when the page is /swift-details.php?id=foo, and the browser properly fills in relative links with the / base. But when the browser goes to a page like /swift/details/foo the base suddenly becomes /swift/ and it tries to append that in front of all relative URLs and thus none of them load.

    You can either make your links absolute, or change the URI base in the header of your pages (inbetween the <head> </head> tags):

    <base href="/">
    
    0 讨论(0)
提交回复
热议问题