【发布时间】:2017-09-25 23:51:07
【问题描述】:
我正在重定向一个 http www。指向新的非 www 的 URL。 https 的域,但一个特定的 URL 模式在结构上发生了变化,所以我想在 htaccess 中为它使用重写规则。
旧:
http://www.example.com/travel.php?cat=cat1&id=1&title=title-string
http://www.example.com/travel/cat1/1/title-string
新:
https://newdomain.com/travel/cat1-title-string
所以对于重定向,“id”参数完全消失了,但我希望“cat”参数和连字符作为新 URL 中“title”参数的前缀。
我认为这是可能的,但我不知道怎么做?如果不是,我将接受没有 cat 参数的规则:
https://newdomain.com/travel/title-string
我想使用 or 表达式来匹配“猫”: (cat1|cat2|cat3)
【问题讨论】:
-
您有两个网址列为“旧”输入。其中哪一个应该转换为新格式?两个?
标签: regex apache .htaccess redirect mod-rewrite