after mod-rewrite, all images file path screw up.

Discussion in 'Programming' started by feelexit, Jun 6, 2007.

  1. #1
    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 ?
     
    feelexit, Jun 6, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Jun 6, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    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
    
    Code (markup):
    !-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.
     
    krakjoe, Jun 6, 2007 IP
  4. feelexit

    feelexit Peon

    Messages:
    143
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thank you I got it. I am using full url , got the problem solved.
     
    feelexit, Jun 7, 2007 IP
  5. mgregoire83

    mgregoire83 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    Please find the attached .htaccess it doen't works with the modifications.

    Help is needed.

    Many thanbks by advance !

    Michel View attachment Htaccess.rar.txt
     
    mgregoire83, Aug 30, 2011 IP