Apache 多个 DocumentRoot
我怎样才能在apache中进行以下设置?
http://server/ABC/*
应由 /var/www/ABC/*
提供
http://server/PQR/*
> 应由 /var/www/PQR/*
提供
所有其他请求 应由 /var/www/Others/index.php
提供>(单个文件)。
谢谢,
JP
How can I have the following setup in apache?
http://server/ABC/*
should be served by /var/www/ABC/*
http://server/PQR/*
should be served by /var/www/PQR/*
Every other request should be served by /var/www/Others/index.php
(a single file).
Thanks,
JP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用别名:
将文档根目录保留为指向 /var/www/Others/index.php。它可以达到目的。 :)
Use Alias:
Leave the document root pointing to /var/www/Others/index.php. It could do the trick. :)
您可以使用 mod_alias 来完成此操作,它是 apache 发行版的一部分。
http://httpd.apache.org/docs/current/mod/mod_alias.html
要使用单个文件提供其他所有内容,您将使用 mod_rewrite。它有很多功能,根据您的需要,您可能需要对其进行调整..但是类似这样的东西应该可以工作:
您可以将其放入文档根目录中的 .htaccess 文件中。
You can do this with mod_alias, which is part of the apache distribution.
http://httpd.apache.org/docs/current/mod/mod_alias.html
for serving everything else with the single file you would use mod_rewrite. This has many features and depending on your needs you might need to tweak that.. but something like this should work:
you would put that in a .htaccess file in the document root.