apache在查看.htaccess之前解析网址

时间:2022-10-06 07:58:41

I have a rewrite rule of the following form:

我有以下形式的重写规则:

RewriteRule ^foo/([a-zA-Z0-9]+)$ foo.php?arg=$1 [qsa,nc]

It takes urls of the form /foo/bar and changes them to /foo.php?arg=bar

它需要/ foo / bar形式的URL并将它们更改为/foo.php?arg=bar

It works properly locally, and it works on my old host but I moved to a new host (running ubuntu) and it behaves differently.

它在本地正常工作,它可以在我的旧主机上运行,​​但我移动到一个新的主机(运行ubuntu),它的行为不同。

On the new host apache notices that there is a foo.php and calls it directly. In other words, urls of the form /foo/bar are seen as /foo.php. If I rename foo.php to foo_junk.php and change the rewrite rule to be

在新主机上,apache注意到有一个foo.php并直接调用它。换句话说,/ foo / bar形式的url被视为/foo.php。如果我将foo.php重命名为foo_junk.php并将重写规则更改为

RewriteRule ^foo/([a-zA-Z0-9]+)$ foo_junk.php?arg=$1 [qsa,nc]

Then it all works. So it's not that I didn't enable overrides or that I failed to install mod_rewrite or anything. Rewrites work, they're just being done at a different point in the process of resolving a url than they are locally.

然后一切正常。所以并不是我没有启用覆盖或者我没有安装mod_rewrite或任何东西。重写工作,它们只是在解析网址的过程中的不同点完成而不是在本地完成。

Is there a configuration option for this?

这有配置选项吗?

1 个解决方案

#1


Try disabling MultiViews:

尝试禁用MultiViews:

Options -MultiViews

#1


Try disabling MultiViews:

尝试禁用MultiViews:

Options -MultiViews