Htaccess/Mod_Rewrite Issue With CSS & Image Files

Discussion in 'Apache' started by natekapi, Dec 10, 2008.

  1. #1
    So I'm trying to make nice URLs for my site by turning urls like: site.com/topic.php into site.com/topic/

    Well, I had that figured out in my htaccess file, but then I realized that it screwed up all my jpgs, gifs, and css files because now it thinks those files are located at site.com/topic/style.css instead of site.com/style.css.

    I really don't want to have to change all my files to link to the full relative URL....so can I do something with htaccess to fix this issue? Help would be very much appreciated! :)
     
    natekapi, Dec 10, 2008 IP
  2. Lexiseek

    Lexiseek Banned

    Messages:
    2,499
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need mod_rewrite to ignore certain directories (like ones in which images and css are kept). Here's how.

    
    RewriteCond %{REQUEST_URI} ^/(cgi-bin|css|images)/?.*$ [NC]
    
    Code (markup):
    If that doesn't work, try this:

    
    RewriteRule ^(|css|images|) - [L]
    
    Code (markup):
     
    Lexiseek, Dec 11, 2008 IP