1

Sorry for the newbie apache question. I'm wondering if it's possible to set up the following non-conventional apache virtualhost (for a Django app):

-- If a file exists in the DocumentRoot (/var/www) it will be shown. So if /var/www/foo.html exists, then it can be seen at www.example.com/foo.html.

-- If file does not exist, it is served via a virtualhost. I'm using mod_wsgi with a WSGIScriptAlias directive that points to a Django app. So if there is no /var/www/bar.html, www.example.com/bar.html will be passed to the Django app, which may or may not be a 404 error.

One option is to create an Alias for each individual file/directory, but people want to be able to post a file without adding an alias, and we want to keep the above URL structure for legacy reasons.

Simplified Virtualhost is:

<VirtualHost *:80> ServerName www.example.com DocumentRoot /var/www WSGIScriptAlias / /path/to/django.wsgi <Directory /path/to/app> Order allow,deny Allow from all </Directory> Alias /hi.html /var/www/hi.html </VirtualHost> 

The goal is to have www.example.com/hi.html work as above, without the Alias line

1

2 Answers 2

1

Documentation on mod_wsgi site on how to do this is at:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive

Use combination of AddHandler and mod_rewrite. Don't use WSGIScriptAlias.

1
  • Yup, that's it. (For others curious, the thread I posted above was also helpful.) You guys are awesome. Commented Nov 22, 2011 at 17:09
0

Using apache I do not believe this is possible, using nGinx however.

... <The rest of your server {} config above> location @fallback { proxy_pass http://<your_uwscgi_server>:<port>; } error_page 404 = @fallback; <any futher server {} configuration> 

I may be wrong, for instance I do not know enough about EnvIF in apache and ether this could be used to provide similar functionality.

2
  • 2
    isn't try_files intended for this? Commented Nov 14, 2011 at 17:22
  • It is possible with Apache and is done all the time with PHP sites. How to do it with mod_wsgi is covered in mod_wsgi documentation. Commented Nov 15, 2011 at 0:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.