阿帕奇 - 映射的URL静态内容的本地路径 [英] Apache - Mapping url to local path for static content

查看:180
本文介绍了阿帕奇 - 映射的URL静态内容的本地路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的httpd.conf

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>

我在/home/www/static/foo/helloworld.txt的文件。如果我去 HTTP://localhost/foo/helloworld.txt 我会看到文件。

现在,对于一些无关痛痒的原因,我想改变的URL。上述网址应返回任何结果,而 HTTP://localhost/bar/helloworld.txt 应该返回文件。我要做到这一点,没有在目录结构进行任何更改。

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.

如何做呢?

推荐答案

您可以使用别名来映射不同的URL路径文件系统路径:

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

Alias /bar /home/www/static/foo

请参阅http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias获取更多信息。

这篇关于阿帕奇 - 映射的URL静态内容的本地路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆