为什么 RewriteBase 不起作用?
这是我正在尝试做的事情:
- 域名为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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
别名需要尾部斜杠。与 RewriteBase 无关。
不过,您可以在需要时使用重写规则添加斜杠。类似于:
将此规则放在服务器根目录的 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:
Put this rule in the htaccess in the root of your server (not in
/xhprof/xhprof_html
)