Home Seo Friendly Url css img js not working
Reply: 2

Seo Friendly Url css img js not working

Ravi Shankar
1#
Ravi Shankar Published in 2015-07-06 09:03:37Z

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]

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

example URL:

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

MaggsWeb
2#
MaggsWeb Reply to 2015-07-06 09:13:48Z

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.

starkeen
3#
starkeen Reply to 2015-07-06 09:18:18Z

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="/">
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.39879 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO