我的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应该返回文件。我想实现这一点,而不改变目录结构中的任何内容。
这是怎么做到的?
最佳答案
您可以使用别名
将不同的url路径映射到文件系统路径:
Alias /bar /home/www/static/foo
参见http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias了解更多信息。
关于Apache - 将 url 映射到静态内容的本地路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6736786/