mod_rewrite 和 php 变量
我正在尝试让 mod_rewrite 与我的网站一起使用,但由于某种原因它不起作用。 我已经在我的 .htaccess 文件中输入代码以将非 www 重定向到 www,所以我知道 mod_rewrite 总体上正在工作。
我试图更改的网址是 example.com/index.php?p=home
所以新的网址将是 example.com/page/home
但是,当我尝试这个代码,我只是得到一个 404 告诉我 /page/home 不存在。
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/p/(.*)/ index.php?p=$1
RewriteRule index/p/(.*) index.php?p=$1
有人可以帮我吗?
I am trying to get mod_rewrite to work with my site but for some reason it's not working.
I've already entered code into my .htaccess file to redirect non-www to www so I know mod_rewrite is working in general.
The url's I'm trying to change are example.com/index.php?p=home
so the new URL would be example.com/page/home
However, when I try this code I simply get a 404 telling me that /page/home doesn't exist.
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/p/(.*)/ index.php?p=$1
RewriteRule index/p/(.*) index.php?p=$1
Can anyone help me out please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
/page/xxxx
您的重写规则使用index/p/xxxxx,但您想尝试
Your rewrite rule uses index/p/xxxxx but you want /page/xxxx
try
您的模式与您的示例网址不匹配。假设您的示例 URL 是正确的,您需要的是:
Your pattern doesn't match your example URL. Assuming your example URL was correct, you wanted this instead: