繁体   English   中英

.htaccess RedirectMatch。 匹配一个单词以外的字符串

[英].htaccess RedirectMatch. Match for string except one word

我需要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/)

http://example.com/category/category-title/.htaccess

包括规则:

RewriteCond %{REQUEST_URI} !^page/
RewriteRule ^(.+)$ http://example.com/product/category-title/$1 [R=301]

转换为:

如果请求的URI 并非page/开头, 遵循下一个RewriteRule

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM