我需要有关 RedirectMatch Regex 指令的帮助。
我需要将以下 URL 重定向如下:
RedirectMatch 301 ^/category/category-title/(.+)(!?/page/)$ http://example.com/product/category-title/$1
我想要的结果是重定向到指定的产品标题,除非找到单词页面:
http://example.com/category/category-title/some-product-title-here
重定向至
http://example.com/product/category-title/some-product-title-here
以下内容不匹配: http://example.com/category/category-title/page/23
编辑:
我有一个具有以下规则的重定向循环:
RedirectMatch 301 ^/categorie/boulangerie-et-patisserie/((?!/page/).+)$ http://recyclageindustriel.com/produit/boulangerie-et-patisserie/$1
RedirectMatch 301 ^/produit/boulangerie-et-patisserie/page/(.*)$ http://recyclageindustriel.com/categorie/boulangerie-et-patisserie/page/$1
感谢您的帮助!
最佳答案
您的否定先行语法不正确,而且位置也错误。
试试这个:
RedirectMatch 301 ^/categorie/boulangerie-et-patisserie/(?!page/)(.+)$ /produit/boulangerie-et-patisserie/$1
RedirectMatch 301 ^/produit/boulangerie-et-patisserie/page/(.*)$ /categorie/boulangerie-et-patisserie/page/$1
正确的否定先行语法是(?!page/)
。
关于php - .htaccess 重定向匹配。匹配除一个单词之外的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33550099/