htaccess - 301 redirect removing part of url

眉间皱痕 提交于 2019-12-02 12:14:48

问题


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


回答1:


You can tweak your regex to match BaTa anywhere like this:

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


来源:https://stackoverflow.com/questions/28011358/htaccess-301-redirect-removing-part-of-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!