...

View Full Version : Rewrite problem



tomharto
10-21-2010, 11:58 PM
I have added this to my .htaccess file


RewriteRule ^([a-z]+)/([0-9]+)$ /bandtest/layout4/$1/$2/ [R]
RewriteRule ^([a-z]+)/([0-9]+)/$ /bandtest/layout4/index.php?page=$1&ID=$2
and it links to the correct file and the variables are correct (for my testing $1=news and $2=46) however all the image files the page contains and the css file dont load. I looked at the source and its looking for them at /bandtest/layout4/news/46/css.css, whereas it needs to be bandtest/layout4/css.css. Anyway i can fix this problem?

P.S Sorry if none of that makes sense, if it doesn't say so and ill try and reword it :)

abduraooft
10-22-2010, 10:46 AM
Anyway i can fix this problem?

P.S Sorry if none of that makes sense, if it doesn't say so and ill try and reword it
It's a common issue when we use mod_rewrite along with relative paths. What you need is change all the relative paths used in the client sides to link img,js,css files to absolute paths starting with /

For example, if the above mentioned file is located at
http://yoursite.com/blog/bandtest/layout4/css.css then the href of your <link> tag should be

href="/blog/bandtest/layout4/css.css"

See http://www.codingforums.com/showthread.php?p=784167#post784167 to read more.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum