Mod_rewrite 无法正常工作

发布于 2024-09-04 08:21:01 字数 440 浏览 1 评论 0原文

我的 .htaccess 文件中有这个...

RewriteEngine on
RewriteRule ^/invite$ /invite.html

它的目的是让用户访问此 url:

http://mysite.com/invite

并显示 invite.html 页面。我不想重定向用户,只是向他们显示来自更好看的 URL 的 invite.html 页面。

但是,当我浏览到 http://mysite.com/invite 时,我收到 404 未找到错误。

我做错了什么吗?我尝试查看使用 mod_rewrite 的教程,但我似乎也在做他们告诉我的事情......

谢谢!

I have this in my .htaccess file...

RewriteEngine on
RewriteRule ^/invite$ /invite.html

It's meant to let a user access this url:

http://mysite.com/invite

and display the invite.html page. I don't want to redirect the user, but just show them the invite.html page from a better looking URL.

When I browse to http://mysite.com/invite though, I get a 404 not found error.

Is there anything I'm doing wrong? I've tried looking at tutorials for using mod_rewrite but I seem to be doing what they're telling me too...

Thanks!

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

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

发布评论

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

评论(3

影子的影子 2024-09-11 08:21:01

我认为 RewriteRule 中不应该有 /

RewriteEngine on
RewriteRule ^invite$ invite.html

I don't think there should be a / in that RewriteRule:

RewriteEngine on
RewriteRule ^invite$ invite.html
薄荷梦 2024-09-11 08:21:01

您是否确保为 .htaccess 文件所在的目录设置了 AllowOverride All?否则该文件可能会被忽略。

如果不是这种情况,您应该查看 Apache 的日志文件以获取更多提示(Linux 上为 /var/log/apache)。

Did you make sure that AllowOverride All is set for the directory where the .htaccess file lies? Else the file might be ignored.

If this isn't the case, you should check out Apache's log files for more hints (/var/log/apache on Linux).

几味少女 2024-09-11 08:21:01

您缺少 RewriteCond 指令。这是执行实际测试条件来匹配 URL 的方法。仅当一个或多个 RewriteCond 匹配时才会调用 RewriteRule。

You're missing a RewriteCond directive. That's the one that does the actual testing Condition to match a URL. The RewriteRule is invoked only when one or more RewriteConds are matched.

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