【问题标题】:erase part of a URL using htaccess rewrite使用 htaccess rewrite 擦除 URL 的一部分
【发布时间】:2013-10-05 12:23:24
【问题描述】:

我需要使用 .htaccess 删除 Joomla/Virtuemart 生成的 SEF URI 的一部分 URI 代表一个菜单层次结构并以这种方式构造:

网上商店 - 内店 -产品目录

这是生成的 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]

我知道这不是好的做法,但我无法更改菜单结构。

有什么建议吗?

【问题讨论】:

    标签: .htaccess mod-rewrite redirect joomla virtuemart


    【解决方案1】:

    此正则表达式 \d+-(.+) 将匹配 1 个或多个数字后跟连字符后跟 1 个或多个任何东西

    试试这个代码:

    RewriteRule ^(online-store)/inner-store/(.*)$ /$1/$2 [R=301,L,NC]
    

    确保这是您.htaccess 中的第一条规则,并使用不同的浏览器对其进行测试以避免缓存问题。

    【讨论】:

    • 嗨@anubhava,似乎可以工作,但现在/online-store 下的所有内容都被重定向到/index.php?option=com_virtuemart。我想德德玛特路由器需要处理
    • 这条规则只会在需要处理掉那个deadmart路由器之后将/online-store/inner-store/product-catalog重定向到/online-store/product-catalog。正如我所建议的那样,只需确保上述规则是您的 .htaccess 中的第一条规则,然后是常规的美德玛特路由器规则。
    猜你喜欢
    • 2018-06-10
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 2015-01-04
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    相关资源
    最近更新 更多