It’s not clear from what you have posted why you are getting a redirect loop. We would need to see the rest of .htaccess
file. However ….
You may be getting a conflict with existing mod_rewrite (ie. RewriteRule
) directives. Redirect
is a mod_alias directive.
You no doubt have existing mod_rewrite directives with the WordPress front-controller. You have other redirects also. You should avoid mixing redirects from both modules since they may not execute in the order you expect (mod_rewrite always runs before mod_alias, despite the apparent order in the config file).
I know there is a flag that makes a rule “final” but …
That “flag” applies to mod_rewrite RewriteRule
, not Redirect
(mod_alias). By adding that flag to Redirect
in this context it will simply be ignored.
You should change these mod_alias Redirect
directives to mod_rewrite RewriteRule
and include them at the very top of your file.
For example:
RewriteRule ^(category)/cat-a/subcat-a/subsubcat-a/(.*) /$1/newcat-a/newsubcat-a/$2 [R=302,L]
RewriteRule ^(category)/cat-b/subcat-b/(.*) /$1/newcat-b/mynewsubcat-b/$2 [R=302,L]
This assumes that everything after the categories are copied onto the end of the target URL. eg. .../subsubcat-a/foo/bar
becomes .../newsubcat-a/foo/bar
. (Which is what your original Redirect
directives would have done.)
$1
is a backreference to “category” (simply saves repetition) and $2
is everything after the category string.
The L
(last
) flag is required here.
Test with 302 and only change to 301 when you are sure it’s working OK – to avoid caching issues.
You will need to clear your browser cache before testing.