.htaccess redirect the permanent site www.domain.com/A to www.domain.com/A/B

A is an empty folder, just used to create my page hierarchy. It contains B, C, which are also folders (not empty)

The hierarchy comes from Apostrophe CMS .

The following rule does not work in .htaccess:

Redirect permanent /A http://www.domain.com/A/B 

because it ends: http://www.domain.com/A/B/B/B/B , etc., since the rule is called again and again.

Can someone point me to a solution? thanks

+1
source share
1 answer

Try using RedirectMatch and include the "end of line" $ in the regular expression.

 RedirectMatch permanent /A$ http://www.domain.com/A/B RedirectMatch permanent /A/$ http://www.domain.com/A/B 

EDIT: The matches below may work a little better (in general)

 RedirectMatch permanent .*/A$ http://www.domain.com/A/B RedirectMatch permanent .*/A/$ http://www.domain.com/A/B 
+3
source

Source: https://habr.com/ru/post/923003/


All Articles