I've got a Django application, and I am utilizing a shared server hosting, and so i cannot change apache's config files. The only real factor will be able to change may be the .htaccess file during my application. I in addition have a standard django.wsgi python file, being an access point.

In dev atmosphere, I am using Django for everyone the static files, but it's frustrated within the official documentation, saying that you ought to get it done while using web server rather.

It is possible to method to serve static files through apache without getting use of Apache's configuration, altering just the .htaccess or django.wsgi files??

The initial step would be to add just

AddHandler wsgi-script .wsgi

for your .htaccess file with little else to determine wsgi because the handler. This makes demands to django.wsgi and django.wsgi/whatever see your django application.

To create the django.wsgi area of the URL disappear, you will have to use mod_rewrite. Hopefully your host has it enabled. A good example is

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

that will serve the file when the URL matches personal files, or perhaps be offered by django whether it does not. Another option is

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^/?static/
RewriteRule ^(.*)$ /django.wsgi/$1 [QSA,PT,L]

to create demands for /static/* visit the file itself and anything else to undergo django.

Then you will have to hide django.wsgi from produced Web addresses. You can do this having a snippet such as this inside your django.wsgi

def _application(environ, start_response):
    # The original application.

import posixpath

def application(environ, start_response):
    # Wrapper to set SCRIPT_NAME to actual mount point.
    environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
    if environ['SCRIPT_NAME'] == '/':
        environ['SCRIPT_NAME'] = ''
    return _application(environ, start_response)

If the does not exercise quite right, then make sure to consult http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines. I drawn the majority of the particulars from the answer after that but simply got the best parts come up with like a step-by-step.

Serve the static files from the different virtual host.