Project

General

Profile

CSS and Images not loading - fixed

Added by Tom Carchrae over 13 years ago

I've just installed 1.0 to my dreamhost account. It went pretty smoothly, with the exception that it would not load stylesheets/images/javascript correctly.

I added the following lines to public/.htaccess:

RewriteCond %{REQUEST_URI} ^/themes.*
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} ^/javascript.*
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} ^/stylesheets.*
RewriteRule .* - [L]

Which disable the re-write rules for the themes/javascript/stylesheets dirs, which were somehow being mangled.

I'm happy... it works. So I post this for two reasons:

1) Maybe it'll make you happy too (if you were like I was an hour ago)

2) Is this 'correct'? Ie, why did I have to do this?


Replies (7)

RE: CSS and Images not loading - fixed - Added by Felix Schäfer over 13 years ago

Does Dreamhost use *cgi or passenger? The .htaccess is known to make passenger cringe when there's also a *cgi enabled in the apache, I think we should change it so that people that want to use *cgi have to do something instead of assuming everyone uses some form of cgi...

RE: CSS and Images not loading - fixed - Added by Tom Carchrae over 13 years ago

I did some sophisticated testing (moving the cgi files around) and it appears it was using the fast cgi way.

Dreamhost does support passenger ( http://wiki.dreamhost.com/Passenger ), but I did not have it turned on. I will try that, but perhaps that will make it cringe more?...

RE: CSS and Images not loading - fixed - Added by Tom Carchrae over 13 years ago

Ok, switching to passenger seemed to have fixed the problem - I removed my rules above and all images are loading ok.

Thanks! :)

RE: CSS and Images not loading - fixed - Added by Felix Schäfer over 13 years ago

Passenger performs a little better, but nothing really noticeable on small-traffic/concurrency deployments, so I wouldn't bother if cgi works for you. What you probably will want to do though is change your RewriteConds to serve files under public directly instead of specifying each directory separately, if you ever install a plugin, its stuff will be put in plugin-assets, which you don't match currently. Having had a quick look at the .htaccess, you probably should already have RewriteCond %{REQUEST_FILENAME} !-f taking care of that.

RE: CSS and Images not loading - fixed - Added by Felix Schäfer over 13 years ago

Tom Carchrae wrote:

Ok, switching to passenger seemed to have fixed the problem - I removed my rules above and all images are loading ok.

Thanks! :)

Don't post while I'm writing answers! :-O Glad it works though :-)

RE: CSS and Images not loading - fixed - Added by Tom Carchrae over 13 years ago

Oops. Thanks for the response though. :)

RE: CSS and Images not loading - fixed - Added by Raphael CPM about 13 years ago

This may seem obvious, but in case it's not: make sure to put the Re-write rules at the top, before it gets to the dispatcher or it'll be too late.

  1. General Apache options
    RewriteEngine On

RewriteCond %{REQUEST_URI} ^/themes.*
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} ^/javascript.*
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} ^/stylesheets.*
RewriteRule .* - [L]

    (1-7/7)