Dan Brown - Credit Cards - Free phpBB forum - Online Advertising - Secured Loans

PDA

View Full Version : after mod-rewrite, all images file path screw up.


feelexit
Jun 6th 2007, 8:52 am
all my php files in theme folder, and images in images folder

http://localhost/theme/
http://localhost/theme/images

I use .htaccess rewrite my ugly url.
http://localhost/theme/category.php?type=movie
http://localhost/theme/category/movie

url works, but all the images in the category.php file cannot be displayed.

in the header.php file, I use <img src="images/logo.jpg">
now, after I rewrite the url, this image file cannot be found. cause, it try to find http://localhost/theme/category/images/logo.jpg
and category acutally does not exist.

I can change it to <img src="../images/logo.jpg">, but problem is header.php is the header file used for all other files.

index.php also use it,http://localhost/theme/index.php
if i change it to ../images/logo.jpg, then index.php couldnt find this image file.


is there a way to give the correct image path for all the files ?

nico_swd
Jun 6th 2007, 9:29 am
I use .htaccess rewrite my ugly url.
http://localhost/theme/category.php?type=movie
http://localhost/theme/category/movie

Because the browser thinks its in another directory. Use the full or absolute URL in your src attribute.

krakjoe
Jun 6th 2007, 11:19 am
or use rewrite conditions to get around it, generally you can get away with using something like


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
// your rewrite rule


!-d instructs apache to rewrite the url if the directory requested does NOT exist on the server
!-f instructs apache to rewrite the url if the file requested does NOT exist on the server

if you post your htaccess, I'll fix it.

feelexit
Jun 7th 2007, 1:13 am
thank you I got it. I am using full url , got the problem solved.