为什么 RewriteBase 不起作用?

发布于 2024-12-27 06:39:05 字数 941 浏览 4 评论 0原文

这是我正在尝试做的事情:

  • 域名为thinkingmonkey.me
  • 域名的 IP 地址为 127.0.0.1
  • mod_alias 已安装。

我有一个名为 directories.conf 的conf 文件。其中我拥有与目录相关的所有配置。 directories.conf 包含在 httpd.conf

我的 directories.conf 包含

Alias /runs /xhprof/xhprof_html

<Directory /mysite/xhprof/xhprof_html>
    Order allow,deny
    Allow from all
    AllowOverride All
</Directory>

/mysite/xhprof/xhprof_html/.htaccess.我有以下内容:

RewriteEngine on
RewriteBase /runs
RewriteRule  .*  index.php

我想做的就是将 /mysite/xhprof/xhprof_html/ 下的任何请求定向到 index.php

当我请求 thinkingmonkey.me/runs 没有尾部斜杠时,我得到 404 not found

因此,我推断 RewriteBase 不起作用。
我做错了什么?

Here is what I am trying to do:

  • domain is thinkingmonkey.me
  • domain has 127.0.0.1 as IP addr
  • mod_alias is installed.

I have a conf file called directories.conf. In which I have all the configuration pertaining to directories. directories.conf is included in httpd.conf

My directories.conf has

Alias /runs /xhprof/xhprof_html

<Directory /mysite/xhprof/xhprof_html>
    Order allow,deny
    Allow from all
    AllowOverride All
</Directory>

In /mysite/xhprof/xhprof_html/.htaccess. I have the following:

RewriteEngine on
RewriteBase /runs
RewriteRule  .*  index.php

All I am trying to do is to direct any request under /mysite/xhprof/xhprof_html/ to index.php.

When I request for thinkingmonkey.me/runs with no trailing slashes I get 404 not found.

So, I infer that RewriteBase is not working.
What am I doing wrong?

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

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

发布评论

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

评论(1

云巢 2025-01-03 06:39:05

别名需要尾部斜杠。与 RewriteBase 无关。

不过,您可以在需要时使用重写规则添加斜杠。类似于:

RewriteRule ^run$ /run/ [R=301,L]

将此规则放在服务器根目录的 htaccess 中(而不是在 /xhprof/xhprof_html 中)

Alias requires a tailing slash. Nothing to do with RewriteBase.

You could use a rewrite rule to add the slash when needed though. Something like:

RewriteRule ^run$ /run/ [R=301,L]

Put this rule in the htaccess in the root of your server (not in /xhprof/xhprof_html)

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