{% if serve_favicon %}Alias {{ url_prefix }}favicon.ico {{ static_path }}/favicon.ico{% endif %}
{% if serve_robots %}Alias {{ url_prefix }}robots.txt {{ static_path }}/robots.txt{% endif %}

{% if serve_static %}Alias {{ static_url }} {{ static_path }}/{% endif %}
{% if serve_media %}Alias {{ media_url }} {{ media_path }}/{% endif %}

{% if redirect_static_to_s3 and aws_s3_base_url %}
# Redirect static to S3
RewriteEngine On
RewriteRule ^{{ static_url }}/(.*)$  {{ aws_s3_base_url }}$1 [R,L]
{% endif %}

WSGISocketPrefix /var/run/wsgi
WSGIProcessGroup {{ wsgi_process_name }}
WSGIPythonOptimize {{ wsgi_python_optimize_level }}
WSGIDaemonProcess {{ wsgi_process_name }} display-name={{ wsgi_process_name }} processes={{ wsgi_processes_count }} threads={{ wsgi_threads_count }} \
    user={{ wsgi_process_user }} group={{ wsgi_process_group }} \
    python-path={{ project_path }}:{{ virtualenv_site_packages_path }}
WSGIScriptAlias {{ url_prefix }} {{ wsgi_script_dirname }}/{{ wsgi_script_filename }} process-group={{ wsgi_process_name }}

<Directory {{ wsgi_script_dir_name }}>
    <Files {{ wsgi_script_file_name }}>
        Order deny,allow
        Allow from all
    </Files>
</Directory>

{% if serve_static %}
<Directory {{ static_path }}>
    Order deny,allow
    Allow from all
</Directory>
{% endif %}

{% if serve_favicon and not serve_static %}
<Directory {{ static_path }}>
    <Files favicon.ico>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
{% endif %}

{% if serve_robots and not serve_static %}
<Directory {{ static_path }}>
    <Files robots.txt>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
{% endif %}

{% if serve_media %}
<Directory {{ media_path }}>
    Order deny,allow
    Allow from all
</Directory>
{% endif %}