How to write htaccess rule to redirect all the url

2019-09-21 18:54发布

问题:

How to write htaccess rule to redirect all the url's that contains the sometext word between the slashes

Ex:

https://www.example.com/sometext/
https://www.example.com/sometext/name.php
https://www.example.com/sometext/sometext/.. 
https://www.example.com/sometext/../../name.php  

ALL THESE need to redirect to a single page.

Thanks for help in advance.

回答1:

Try this then:

RedirectMatch ".*\/sometext(.*?)\/" "http://www.example.com/page-to-be-redirected"


回答2:

Just:

RewriteRule ^sometext/ /page.htm [R=301]