![](/img/trans.png)
[英]htaccess URL Rewrite - Root to Subfolder (with folder of the same name)
[英].htaccess rewrite product URL to root category
在编写重写规则时遇到问题,我的正则表达式技能有些缺乏,因此我正在阅读教程并编写示例...但是似乎无法理解...
# from /boys/footwear/socks/surfs_up_kids_three-pack_socks/product.aspx?productid=4407&deptid=365
# to /boys/footwear.html
RewriteRule ^.*boys/footwear/socks/([^/]+)/product\.aspx([^/]+)$ /boys/footwear.html [R=301,L,NC]
这个想法是要匹配在URL中为其分配了男孩/鞋/袜子和product.aspx的所有产品。 虽然我也希望能够根据情况进行调整...因为它可能并不总是product.aspx
我第一次做错了什么...导致多数民众赞成在令人讨厌的部分。 我没有运气就遵循了数十个教程和示例...我知道这是最小的事情...
感谢大家的投入!
更新
假定此方法可以根据以下方法工作: http : //htaccess.madewithlove.be/ (但是在网站上不起作用?)
RewriteRule ^(.*)boys/footwear/socks/(.*)/product.aspx(.*)$ $1boys/footwear/socks.html [R=301,L,NC]
不知道改写正则表达式的用法,但是由于没有人回答,我想我可能会把您引向正确的方向。
# from /boys/footwear/socks/surfs_up_kids_three-pack_socks/product.aspx?productid=4407&deptid=365
# to /boys/footwear.html
RewriteRule ^boys/footwear/socks/([^/]+)/product.aspx([^/]+)$
只需要逃避product和aspx之间的点。
根据需要添加捕获组以组成替换。
^.*/boys/footwear/socks/[^/]+/product\.aspx[^/]+$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.