mod_rewrite 用户 ID 错误
我是重写 url 的新手,想知道如何重写
From this /个人资料/4
到此 /profile.php?id=4
到目前为止,我有此规则
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1
,但它在浏览器中显示此内容
Firefox 已检测到服务器正在以永远不会完成的方式重定向对此地址的请求。
在浏览器地址栏中显示/profile/4/index.php,这是不正确的。
.htaccess 文件
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
#ErrorDocument 404 /test.php
DirectoryIndex test.php
RewriteRule settings editProfile.php
RewriteRule update update.php
RewriteRule home test.php
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1
I'm new to rewriting urls and wanted to know how i would rewrite
From this
/profile/4
To this
/profile.php?id=4
I have this rule so far
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1
but it displays this in the browser
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
It displays /profile/4/index.php in the browser address bar which is incorrect.
.htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
#ErrorDocument 404 /test.php
DirectoryIndex test.php
RewriteRule settings editProfile.php
RewriteRule update update.php
RewriteRule home test.php
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你已经差不多了。尝试使用这个,
我在网上找到了这个很好的免费资源,可以帮助您在测试您的重写规则之前将它们发布到您的实时网站。这可能对未来有所帮助。看来您的规则应该像您发布的那样起作用。问题一定出在其他地方。
You are pretty much there. Try using this instead
I found this good free resource online to help you test your rewrite rules before you post them to your live site. This may help for the future. It looks like your rule should work as you have it posted though. The problem must be somewhere else.
你的规则很好,所以有一个重定向与它相冲突。我想您在
/profile/4
处没有真正的目录,因此剩下的主要候选目录是 mod_negotiation。试试这个:Your rule is just fine so there's a redirection somewhere conflicting with it. I suppose that you don't have a real directory at
/profile/4
so they main candidate left is mod_negotiation. Try this: