为什么fatfree需要Mac上的RewriteBase但不需要Ubuntu?(Why does fatfree need a RewriteBase on Mac but not Ubuntu?)

编程入门 行业动态 更新时间:2024-10-24 22:17:58
为什么fatfree需要Mac上的RewriteBase但不需要Ubuntu?(Why does fatfree need a RewriteBase on Mac but not Ubuntu?)

我最近在Ubuntu上使用过FatFree,并且在将它放入子目录时没有任何问题。 但是,我最近尝试在Mac上的用户网站(10.6.8)中执行此操作,并遇到了需要RewriteBase才能使路由工作的问题 。

我想知道是否有人知道为什么Ubuntu上的默认Apache设置似乎允许路由在.htaccess中没有RewriteBase的情况下工作,但Mac上的设置使其成为必要。

Ubuntu安装程序使用一堆VirtualHosts,而Mac配置只有一个服务器配置,mod_userdir启用和每个用户的Sites目录的指令。

I've used FatFree quite a lot recently on Ubuntu, and have had no problems putting it into subdirectories. However, I recently tried to do this in a user website on Mac (10.6.8) and ran into the problem of needing a RewriteBase for the routing to work.

I was wondering if anyone has any idea why the default Apache setup on Ubuntu seems to allow the routing to work without a RewriteBase in the .htaccess, but the setup on Mac makes it necessary.

The Ubuntu setup uses a bunch of VirtualHosts, whereas the Mac config just has a server config, mod_userdir enabled and a directive for each user's Sites directory.

最满意答案

mod_rewrite文档说除非满足以下任一条件,否则需要RewriteBase指令:

原始请求和替换位于DocumentRoot的下方(而不是通过其他方式可以访问,例如Alias)。 包含RewriteRule的目录的文件系统路径(以相对替换为后缀)也可用作服务器上的URL路径(这种情况很少见)。

第一个条件可能是您的Ubuntu设置,但不是Mac设置,因为您使用的是mod_userdir。 如果将文件从〜/ Sites移动到DocumentRoot(Mac上默认为/ Library / Webserver / Documents),则可能不再需要RewriteBase。

The mod_rewrite documentation says that the RewriteBase directive is required unless either of the following conditions are true:

The original request, and the substitution, are underneath the DocumentRoot (as opposed to reachable by other means, such as Alias). The filesystem path to the directory containing the RewriteRule, suffixed by the relative substitution is also valid as a URL path on the server (this is rare).

The first condition is probably met with your Ubuntu setup but not with your Mac setup, since you are using mod_userdir. If you move your files from ~/Sites to the DocumentRoot (default on Mac is /Library/Webserver/Documents), chances are that you won't need the RewriteBase anymore.

更多推荐

本文发布于:2023-08-01 02:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1351725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但不   Mac   fatfree   Ubuntu   RewriteBase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!