开发者

Apache - Mapping url 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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜