开发者

Apache - Mapping url to local path for static content

开发者 https://www.devze.com 2023-03-21 07:23 出处:网络
My httpd.conf <VirtualHost *:80> ... DocumentRoot /home/www/static ... <Directory /home/www/static>

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 at /home/www/static/foo/helloworld.txt. And if I go to http://localhost/foo/helloworld.txt I will see that file.

Now, for some 开发者_如何学编程irrelevant reason, I want to change the urls. The above url should return nothing, while http://localhost/bar/helloworld.txt should return the file. And I want to achieve this, without changing anything in the directory structure.

How is that done?


You can use Alias to map different url paths to filesystem paths:

Alias /bar /home/www/static/foo

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

0

精彩评论

暂无评论...
验证码 换一张
取 消