Apache 多个 DocumentRoot

发布于 2024-10-09 10:59:34 字数 287 浏览 0 评论 0原文

我怎样才能在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫言歌 2024-10-16 10:59:34

使用别名:

Alias /ABC/ /var/www/ABC/
Alias /PQR/ /var/www/PQR/

将文档根目录保留为指向 /var/www/Others/index.php。它可以达到目的。 :)

Use Alias:

Alias /ABC/ /var/www/ABC/
Alias /PQR/ /var/www/PQR/

Leave the document root pointing to /var/www/Others/index.php. It could do the trick. :)

淡看悲欢离合 2024-10-16 10:59:34

您可以使用 mod_alias 来完成此操作,它是 apache 发行版的一部分。

http://httpd.apache.org/docs/current/mod/mod_alias.html

要使用单个文件提供其他所有内容,您将使用 mod_rewrite。它有很多功能,根据您的需要,您可能需要对其进行调整..但是类似这样的东西应该可以工作:

RewriteEngine on
RewriteRule ^(.*)$ /index.php?path=$1 [L]

您可以将其放入文档根目录中的 .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:

RewriteEngine on
RewriteRule ^(.*)$ /index.php?path=$1 [L]

you would put that in a .htaccess file in the document root.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文