Apache - URL mapping to local path for static content

My httpd.conf

<VirtualHost *:80> ... DocumentRoot /home/www/static ... <Directory /home/www/static> Order Allow,Deny Allow from all </Directory> <Location "/foo"> SetHandler None </Location> </virtualhost> 

I have a file on /home/www/static/foo/helloworld.txt. And if I go to http: //localhost/foo/helloworld.txt , I will see this file.

Now, for some irrelevant reason, I want to change the URL. The above URL should not return anything, and http: //localhost/bar/helloworld.txt should return a file. And I want to achieve this without changing anything in the directory structure.

How it's done?

+4
source share
1 answer

You can use Alias to map different URL paths to file system paths:

 Alias /bar /home/www/static/foo 

See http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias for more details.

+10
source

All Articles