Forum Moderators: phranque

Message Too Old, No Replies

my css styles and images disappeared after URL rewriting with htaccess

css styles not working after url rewriting

         

rashidfarooq

11:01 am on Nov 1, 2011 (gmt 0)

10+ Year Member



When I Rewrite my URL
http://www.example.com/product.php?productname=bicycle

To
http://www.example.com/products/bicycle/

It was successfully redirected / rewritten but all of my css styles and images disappeared. I could not understand the problem. Can Any one explain?

lucy24

10:56 pm on Nov 1, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, this is the Big Peril of rewriting (not redirecting). The browser thinks you are at the originally requested location

http://www.example.com/product.php

so if the images and css are called by relative links (ones that do not begin in a / slash) it is looking for them in

http://www.example.com/

rather than in

http://www.example.com/products/bicycle/

Change all your image and css links to site-absolute ones and it will work.

rashidfarooq

5:01 am on Nov 2, 2011 (gmt 0)

10+ Year Member



Thanks a lot lucy24.
My Problem is solved now. You are right. It was a problem of slash. Now I put the slash (/) before the beginning of path. Now it is working fine.
Thanks a lot for helping.

g1smd

7:27 am on Nov 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Always use a leading slash for all links within a site - images, stylesheets, javascript, etc.