Apache RewriteRule .* index.php [NC,L] 不工作

发布于 2024-08-24 15:35:01 字数 664 浏览 4 评论 0原文

我试图将所有内容从我的 /website/folder/ 目录重定向到单个页面。

我用这个简单的代码添加了一个简单的 .htaccess (我知道这需要在 .htaccess 中添加更多代码,但这只是一个测试)。

RewriteEngine on
RewriteRule .* index.php [NC,L]

当我尝试时:

http://127.0.0.1:8888/website/folder/fileDoesntExistMustGoIndex

我遇到“未找到对象 404”错误,并且 access.log 显示:

127.0.0.1 - - [13/Mar/2010:13:48:31 -0500] "GET /website/folder/fileDoesntExistMustGoIndexHTTP/1.1" 404 1118

我已检查 httpd.conf,但没有看到任何可以更改此 .htaccess 语句的内容。有什么想法吗?

编辑:

RewriteEngine on
RewriteRule .* http://www.google.ca [NC,L]

这有效......但当我尝试重写我的页面时则无效。

I am trying to redirect everything to a single page from my /website/folder/ directory.

I added a simple .htaccess with this simple code (I know this would require more code in .htaccess but it's just a test).

RewriteEngine on
RewriteRule .* index.php [NC,L]

When I try :

http://127.0.0.1:8888/website/folder/fileDoesntExistMustGoIndex

I have an "Object not found 404" error and the access.log display:

127.0.0.1 - - [13/Mar/2010:13:48:31 -0500] "GET /website/folder/fileDoesntExistMustGoIndexHTTP/1.1" 404 1118

I have check the httpd.conf and I see nothing that could alter this .htaccess statement. Any idea?

Edit:

RewriteEngine on
RewriteRule .* http://www.google.ca [NC,L]

This works... but not when I try to rewrite to a page of mine.

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

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

发布评论

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

评论(1

单调的奢华 2024-08-31 15:35:01
RewriteEngine On
RewriteBase /
RewriteRule . index.php

也尝试

RewriteLog "rewrite.log"
RewriteLogLevel 3

看看会发生什么

RewriteEngine On
RewriteBase /
RewriteRule . index.php

also try

RewriteLog "rewrite.log"
RewriteLogLevel 3

to see what happens

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