php中的url重写
海
我对apache mod_rewrite还有一个疑问。 我想重写网址 mydomain/index.php?category=1&id=1 到 mydomain/索引/类别/1/id/1 我如何在 .htaccess 中编写规则
我必须在 a 标记内给出的链接是什么
请给我一个解决方案..
Hai
I have one more doubt in apache mod_rewrite.
I want to rewrite the url
mydomain/index.php?category=1&id=1
To
mydomain/index/category/1/id/1
How I write rule in .htaccess
And what is the link that i have to give inside the a tag
Please give me a solution..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未经测试,但值得一试:
您的网址可以看起来与您提到的方式完全相同:
Not tested, but worth a shot:
Your URLs can look exactly like the way you mentioned:
在
标签内,您将使用很好的链接,即
category/1/id/1
(这正是您使用mod_rewrite< /code>,以便能够使用漂亮的 URL!)
至于规则,请尝试类似(未经测试)的内容:
实际上我宁愿使用
So you can direct call
mydomain/1/1
但你得到了我希望编辑的想法:
&%{QUERY_STRING}
部分对于您的要求来说不是必需的,但我通常会包含它,以防我想传递任何额外的参数到页面。Inside the
<a>
tags you will use the nice link, that iscategory/1/id/1
(that's exactly why you're usingmod_rewrite
, to be able to use nice URLs!)As for the rule, try something like (untested):
Actually I would rather use
So you can call directly
mydomain/1/1
but you got the idea I hopeEDIT: the
&%{QUERY_STRING}
part is not necessary for what you asked, but I generally include it in case I want to pass any extra parameter to the page.