Apache alias with

apache-2.4

I currently have a python project running on my apache server using the setup:

<VirtualHost *:80>
    ServerName domain.tld
    <Location />
        SetHandler uwsgi-handler
        uWSGISocket /run/uwsgi/app/site/socket
    </Location>
</VirtualHost>

But I have a few URLs that i don't want to go through the uwsgi handler. I've tried using Alias but it seems to be overriden by <Location /> when i do:

<VirtualHost *:80>
    ServerName domain.tld
    Alias /file.name /var/www/site/static/file.name
    <Location />
        SetHandler uwsgi-handler
        uWSGISocket /run/uwsgi/app/site/socket
    </Location>
</VirtualHost>

I've tried a bunch of variation (different location/alias order, ProxyPass, rewrites) but every time <Location /> takes precedence.

Best Answer

Your question boils down to the order of precedence in which sections within the configuration are merged. Location happens last and Apache Location directives are matched in order so you need something to unset uwsgi for the some parts like:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/wwww/site/static
    <Location />
        SetHandler uwsgi-handler
        uWSGISocket /run/uwsgi/app/site/socket
    </Location>
     <Location /file.name>
        SetHandler none
    </Location>
</VirtualHost>