.htaccess 不必要的 Pinterest 数组重定向到实际 URL
.htaccess unnecessary Pinterest arrays redirection to actual URL
如何重定向此模式
example.com/fruits/7285/good-slug","id":"33b4","favicon_link":"https:/i.pinimg.com/fa/9.png
对此:
example.com/fruits/7285/good-slug
尝试过:
RewriteEngine on
RewriteRule ^(fruits/\d+/[\w-]+). / [R=301,L,NC,NE]
但是重定向太多了。
Pinterest 通过在我的 URL 之后添加一些数组来引用这样的 URL(abc.com/fruits/123/slug),我不知道如何,所以我需要重定向到我实际的。
您可以将此重定向规则与 possessive quantifier:
一起使用
RewriteRule ^(fruits/\d+/[\w-]++). / [R=301,L,NC,NE]
[\w-]++
匹配匹配单词或连字符的最长可能字符串,没有任何回溯。
另一方面,^(fruits/\d+/[\w-]+).
将导致重定向循环,因为正则表达式引擎回溯以允许匹配 [\w-]+
模式后的单个字符。
如何重定向此模式
example.com/fruits/7285/good-slug","id":"33b4","favicon_link":"https:/i.pinimg.com/fa/9.png
对此:
example.com/fruits/7285/good-slug
尝试过:
RewriteEngine on
RewriteRule ^(fruits/\d+/[\w-]+). / [R=301,L,NC,NE]
但是重定向太多了。
Pinterest 通过在我的 URL 之后添加一些数组来引用这样的 URL(abc.com/fruits/123/slug),我不知道如何,所以我需要重定向到我实际的。
您可以将此重定向规则与 possessive quantifier:
一起使用RewriteRule ^(fruits/\d+/[\w-]++). / [R=301,L,NC,NE]
[\w-]++
匹配匹配单词或连字符的最长可能字符串,没有任何回溯。
另一方面,^(fruits/\d+/[\w-]+).
将导致重定向循环,因为正则表达式引擎回溯以允许匹配 [\w-]+
模式后的单个字符。