如何创建使用.htacces modrewrite更好网址

编程入门 行业动态 更新时间:2024-10-16 02:31:27
本文介绍了如何创建使用.htacces modrewrite更好网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的网址正确nowm我的产品

This are my urls right nowm for my products

www.example/product.php?product=32723

我想实现这个

www.example/product/32723-brand-模型产品名

我一直在修改我的.htaccess但真的就如何实现这一目标没有头绪。

I have been modifying my .htaccess but really with no clue on how to achieve this.

推荐答案

您必须将网址与的 重写规则 模式和重写到目标URL

You must match your URL with a RewriteRule pattern and rewrite it to the target URL

RewriteRule ^/product/(\d+)- /product.php?product=$1

这个模式匹配开头 /产品/ 的任何URL,并抓住了以下数字(\ d +)之后破折号 - 。替换URL将是 /product.php?product = 与所捕获的数字 $ 1 追加。

This pattern matches any URL starting with /product/ and captures the following digits (\d+) followed by a dash -. The substitution URL will be /product.php?product= with the captured digits $1 appended.

要捕捉比赛的某些部分,你将它用括号(...)。了解更多关于在mod_rewrite的在 URL重写简介经常使用前pressions - 普通防爆pressions 。

To capture some part of the match, you enclose it in parenthesis (...). Read more on regular expressions used in mod_rewrite at Apache mod_rewrite Introduction - Regular Expressions.

更多推荐

如何创建使用.htacces modrewrite更好网址

本文发布于:2023-11-02 04:04:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551321.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   htacces   modrewrite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!