我需要使用.htaccess删除部分Joomla / Virtuemart生成的SEF URI URI表示菜单层次结构,并以这种方式构建:
在线商店 - 内店 -product-目录
这是结果URI:
www.domain.com/online-store/inner-store/product-catalog
我想将其更改为:
www.domain.com/online-store/product-catalog
认为这可能有所帮助,但它没有任何区别
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online-store/inner-store/\d+-(.+) /online-store/$1 [R=301,L]
我知道它不被认为是好的做法,但我不能改变菜单结构。
有什么建议吗?
答案 0 :(得分:2)
此正则表达式\d+-(.+)
将匹配1位或更多位数后跟连字符后跟1或更多任何内容
请尝试使用此代码:
RewriteRule ^(online-store)/inner-store/(.*)$ /$1/$2 [R=301,L,NC]
确保这是.htaccess
中的第一条规则,并使用其他浏览器对其进行测试以避免缓存问题。