使用 mod_rewrite 的 .htaccess 新手问题
我需要为我的网站创建 SEO 友好的 URL。我发现我可以使用 .htaccess 来重写它们。所以我尝试了这个:
> http://www.domain.com/page/1/mypage
> http://www.domain.com/user/2/myuser
> http://www.domain.com/help/3/myhelp
现在我陷入了一个共同的规则,我不明白Ant根据页面名称重定向流量:
我使用:
RewriteEngine ON
RewriteRule ^(.*)$ page.php?page=$1
然后在我的PHP中我没有正确获取页面,我得到了文件是错误的。
我该如何解决这个问题?
I need to create SEO-friendly urls for my site. I found out I can use .htaccess
to rewrite them. So I tried this:
> http://www.domain.com/page/1/mypage
> http://www.domain.com/user/2/myuser
> http://www.domain.com/help/3/myhelp
Now I am stuck with a common rule and I don't understand Ant to redirect traffic based on the name of the page:
I use:
RewriteEngine ON
RewriteRule ^(.*)$ page.php?page=$1
Then in my PHP I don't get the page correctly, I get the file which is wrong.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是您需要执行的操作:
NC(或 nocase)使测试用例不敏感,A = a;
L(或最后)最后一条规则。在此停止重写过程,不再应用任何重写规则;
您可以在 http://httpd.apache.org/docs/current 获取更多信息/mod/mod_rewrite.html
Here's what you need to do:
NC (or nocase) Makes the test case-insensitive, A = a;
L (or last) Last rule. Stop the rewriting process here and don't apply any more rewrite rules;
You can get more info at http://httpd.apache.org/docs/current/mod/mod_rewrite.html