Well, Mapping a URL Path to a directory can be useful in many scenarios,

Ex:

  • As a proof of ownership, some sites may ask you to publish certain files in certain directories “Google WebSite Ownership Verification, etc…
  •  Publishing Django static files while proxying all the other URLs. Django Developers will relate 🙂
  • etc…

So, there are multiple ways to do it, But the below 2 methods are v. simple and accomplish the required task,

1- using ‘Alias’, this method also works for directories outside the DocumentRoot

Alias /static /path/to/django/staticdir

2- using mod_rewrite to accomplish this

RewriteEngine On
RewriteRule ^/static/(.+)$ /path/to/django/staticdir/$1

References:

– https://httpd.apache.org/docs/1.3/urlmapping.html

– https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html

 

[amazon_link asins=’B01LD8K69M,B00B8X360O,8850328176,0596518889,8871924029′ template=’ProductCarousel’ store=’ipvx-21′ marketplace=’IT’ link_id=’4a019aa1-498f-11e8-843e-d98b75b5389b’]