重定向永久字符串替换

Redirect permanent string replacement

我想要 URL:

https://example.com/en/category/post+name_tour123456

指向:

https://example.com/en/category/post+name+123456

我要删除_tour

我可以用 .htaccess 做吗?

我创建了一个正则表达式来匹配所有这些链接:

((http[s]?):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([^_]+(?=_)*)(\W?_tour?)([0-9]*)

谢谢

因此您可以根据请求进行匹配。试试这个规则,看看它是如何工作的。

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /en/category/(.+)\+(.+)\+_tour(.*) [NC]
RewriteRule ^ /en/category/%1+%2+%3 [R=301,L]