简体   繁体   中英

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:
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:
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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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