未找到 Htaccess 重写
我正在使用Mod Rewrite来删除index.php。我不想使用查询。我希望 foo.com/bar 被解释为 foo.com/index.php/bar。
它做得很好,但给我未找到错误。在此服务器上找不到请求的 URL /home/foo/www/index.php/bar。
为什么!!
I'm using Mod Rewrite to remove index.php. I do not want to use queries. I want foo.com/bar to be interpreted as foo.com/index.php/bar.
It does this fine, but gives me Not Found error. The requested URL /home/foo/www/index.php/bar was not found on this server.
Why!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新
我想我刚刚弄清楚你想要做什么。你看,你可以在幕后传递查询,但你不能在幕后传递你的建议。您必须进行实际的重定向。像这样的东西(重要的部分是
R
):这会强制使用新的特殊路径重定向到您的页面。这就是你想要的吗?
原始答案
您不能将路径传递到这样的 PHP 页面,因为它将被解释为路径的一部分。您的文件很可能位于 Linux/Unix 计算机上,其中的目录可以使用
.
命名。抱歉,但您必须使用查询字符串:或 更新:
我还认为 Windows 的最后几个版本支持目录中的
.
好吧,但我不确定。Update
I think I just figured out what you are wanting to do. You see, you can pass queries behind the scenes, but you cannot pass what you are suggesting behind the scenes. You have to do an actual redirect. Something like this (The important part is the
R
):This forces a redirect to your page using the new special path. Is that what you wanted?
Original Answer
You cannot pass a path to a PHP page like that as it will be interpreted as part of a path. Chances are, your file is on a Linux/Unix machine where a directory can be named with a
.
in it. Sorry, but you will have to use a query string:Or updated:
I also think the last few versions of windows support
.
in directories as well, but I am not sure.index.php
几乎可以肯定是一个文件,而不是目录,除非您(奇怪地)有一个名为index.php
的目录。 Apache 正确地抱怨没有这样的目录。您可能打算执行类似
index.php?page=bar
的操作。相应地调整您的.htaccess
。index.php
is almost certainly a file, not a directory, unless you (bizarrely) have a directory calledindex.php
. Apache is correctly complaining that there is no such directory.You probably meant to do something like
index.php?page=bar
. Adjust your.htaccess
accordingly.