ProfHase85
ProfHase85

Reputation: 12193

serving static files with .htaccess

I am trying to redirect all requests to my site to my cgi script (django.cgi) What should happen:

  1. Calling www.mysite.de/bla/anything.html shall be redirected to the django.cgi
  2. Calling www.mysite.de/static/anything/my.css shall be redirected to a static folder

/home/page/my_site/static/anything/my.css

So far I ve got the following .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^static/(.*)$ my_site/static/$1
RewriteRule ^(.*)$ django.cgi/$1 [QSA,L]

This one gives me a 500 error. If I comment out the third line, anything works fine except for the static files are not served. How should my .htaccess look like?

Upvotes: 0

Views: 2630

Answers (1)

Mike Rockétt
Mike Rockétt

Reputation: 9007

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/static
RewriteRule ^ ../static/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ django.cgi [QSA,L]

I have moved the rule for static files up prior to the CGI rewrite. I have also used a jump to the previous folder as it is not clear as to where your .htaccess file is. If the rules do not work, please comment with the location of this file (it should b in your DOCUMENT_ROOT.

Upvotes: 2

Related Questions