本地服务器上每个项目的 httpd.conf 重写规则

发布于 2024-09-25 04:57:52 字数 157 浏览 0 评论 0原文

我在同一台本地服务器上托管多个项目,并且想知道是否可以将每个项目的重写规则放在 httpd.conf 文件中,而不是放在每个项目的 .htaccess 文件中。

httpd.conf 文件中的语法是否与 .htaccess 完全相同,因为我以前从未使用过它?

谢谢。

I am hosing multiple projects on the same local server and was wondering if it was possible to put the rewrite rules for each project in the httpd.conf file rather than in the .htaccess file for each project.

Is the syntax exactly the same in the httpd.conf file to .htaccess because I've never used it before?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

妄断弥空 2024-10-02 04:57:52

是的,有可能:

此模块对每个服务器上下文 (httpd.conf) 和每个目录上下文 (.htaccess) 中的完整 URL(包括路径信息部分)进行操作 [...]

在 .htaccess 文件中使用 mod_rewrite 和在 .htaccess 文件中使用 mod_rewrite 之间的主要区别在不同的 上下文 中是以下模式的语法RewriteRule

在 .htaccess 文件中使用重写引擎时,每个目录的前缀(对于特定目录始终相同)会自动删除以进行模式匹配,并自动添加 em> 替换完成后。

因此,虽然路径前缀之前已被删除,因此也必须从模式中删除,但在任何其他上下文中使用时必须提供完整路径。

Yes, it is possible:

This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) […]

The main difference between using mod_rewrite in an .htaccess file and in a different context is the syntax of the pattern of RewriteRule:

When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the pattern matching and automatically added after the substitution has been done.

So while the path prefix is removed before and thus must also be removed from the pattern, the full path must be provided when using in any other context.

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