Question

I have a httpd.conf file that looks like this:

Alias /robots.txt /var/www/tech_eval/static/robots.txt
Alias /favicon.ico /var/www/tech_eval/static/favicon.ico

AliasMatch /([^/]*\.css) /var/www/tech_eval/static/styles/$1

Alias /media/ /var/www/tech_eval/static/media/

<Directory /var/www/tech_eval/static>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias /tech_eval /var/www/tech_eval/scripts/django.wsgi

<Directory /var/www/tech_eval/scripts>
Order allow,deny
Allow from all
</Directory>

This works fine for my tech_eval project, but it's starting to cause problems with other sites. I think it might be appropriate me for to move all this stuff to a .htaccess file located in the tech_eval folder so that it doesn't cause problems. Although, I don't think all these options will work when ran from a .htaccess will they? What are my options? I mean, I could fix this by prefixing everything with tech_eval but then I'd wind up with one big master file for all my sites and it would just become a big mess.

Was it helpful?

Solution

It isn't actually too clear what problem you are trying to solve. Why are you even using that configuration in the first place? It looks like you just copied it from mod_wsgi documentation without understanding what each bit does and started using it when it isn't even appropriate for your setup. Specifically that example in mod_wsgi documentation was a generic example and not necessarily suited for Django.

So, rather that trying to fix that configuration to meet some unknown goal, just describe what you need and will tell you what the proper configuration is that you should be using.


UPDATE 1

Per my comment below, perhaps then use:

AliasMatch /tech_eval/([^/]*\.css) /var/www/tech_eval/static/styles/$1

Alias /tech_eval/media/ /var/www/tech_eval/static/media/

<Directory /var/www/tech_eval/static>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias /tech_eval /var/www/tech_eval/scripts/django.wsgi

<Directory /var/www/tech_eval/scripts>
Order allow,deny
Allow from all
</Directory>

Just ditch robots.txt and favicon.ico, or at least don't get them from sub URL site and just stick them direct in the DocumentRoot directory and use those which truly are for whole of site.

I think it is 'ADMIN_MEDIA_PREFIX' in Django settings module that you then need to change to '/tech_eval/media/'.

For Django don't think you even need to CSS alias and that is where this was originally a generic example to show concepts rather than be something which was correct for Django.

Anyway, everything is then under '/tech_eval' and shouldn't interfere with other applications on same site.

OTHER TIPS

Use VirtualHosts to limit the scope of these lines, and an include per virtual host to organize your config files and keep it from growing unwieldy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top