简体   繁体   English

htaccess-301重定向,删除部分网址

[英]htaccess - 301 redirect removing part of url

I'm not able to get to work this 301 redirect, i have to remove "BeTa" word from all the request, and redirect: 我无法使用此301重定向,我必须从所有请求中删除“ BeTa”一词,然后重定向:
FROM: http://www.example.com/BeTa/other/content TO: http://www.example.com/other/content

"BeTa" could also be present in other part of url: 网址的其他部分也可能包含“ BeTa”:
FROM: http://www.example.com/bla/BeTa/other/content TO: http://www.example.com/bla/other/content

is it possible? 可能吗? Right now I have only tried the first part: 现在,我只尝试了第一部分:

RewriteEngine on
RewriteRule ^/BeTa/(.*)$ /$1 [R=301,L]

thanks in advance 提前致谢

You can tweak your regex to match BaTa anywhere like this: 您可以调整正则表达式以匹配BaTa ,如下所示:

RewriteEngine on
RewriteRule ^(.+?/)?BeTa(?:/(.*))?$ /$1$2 [NC,R=301,L]

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

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