mod_rewrite:帮助重写 URL
我有一个网站,我正在尝试重写它的网址。
这很简单,但我不明白该怎么做。
页面如下:
http://localhost/site/index.php?p=home等。home是一个参数,重写应该是这样的:http:// /localhost/site/home.html
http://localhost/site/section.php?id=someid 我希望它像 http://localhost/站点/来自数据库 SOMEID 的部分名称
http://localhost/site/product.php?id=someid 我希望它像 http://localhost/site/category-name/product-name-SOMEID< /strong>
我认为这很简单,但我仍然不明白该怎么做。请帮我。
谢谢!
I have a website and I'm trying to rewrite it's url.
It's pretty simple, but i'm not understanding how to do it.
The pages are the next ones:
http://localhost/site/index.php?p=home, etc. home is a parameter, and rewrite should be like this: http://localhost/site/home.html
http://localhost/site/section.php?id=someid and i want it to be like http://localhost/site/the-name-of-the-section-from-database-SOMEID
http://localhost/site/product.php?id=someid and i want it to be like http://localhost/site/category-name/product-name-SOMEID
I think it's simple, but I still don't understand how to do it. Please, help me.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://net.tutsplus.com/教程/其他/a-deeper-look-at-mod_rewrite-for-apache/
使用此链接有关于 mod_rewrite 的详细说明。而且我认为 anubhava 的正则表达式是正确的
http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/
use this link in has a detail ehplanation about mod_rewrite.also i think anubhava got the regex right
将这些行放入您的 ROOT .htaccess 中:
Put these lines in your ROOT .htaccess:
此页面应该可以帮助您.htaccess 网址重写生成器。它会为您生成 htaccess 文件。
this page shoul help you .htaccess Url Rewrite Generator. it generates htaccess files for you.