小编Mar*_*wen的帖子

HTACCESS 重定向,并在 url 中进行单词替换

我在使用这个正则表达式时遇到了问题,我认为它是正确的,但它不起作用。我想做的是重定向一堆包含特定字符串的网址,如下所示:

http://www.example.com/**undesired-string**_another-stringtohttp://www.example.com/**new-string**_another-string

http://www.example.com/folder/**undesired-string**/another-stringtohttp://www.example.com/folder/**new-string**/another-string

所以我在 .htaccess 中有这段代码:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule (.+)+(undesired-string)+(.+) $1new-string$2 [R=301,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

这应该将任何 url 中的任何不需要的字符串替换为新字符串,但它不起作用,知道为什么吗?

谢谢

regex .htaccess mod-rewrite

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

.htaccess ×1

mod-rewrite ×1

regex ×1