Reputation: 167
I have been trying to do a batch redirect from hee old URL to the new one. However I think I might be doing something wrong. The redirect works but partially.
RewriteRule ^blogs/blog/.*$ https://elashsupplies.com.au/blog/$1 [L,R=301]
RewriteRule ^blogs/blog/tagged/.*$ https://elashsupplies.com.au/blog/tag/$1 [L,R=301]
This redirects the URL but only to /blog not to the post it self. Was wondering what I might be doing wrong and how to fix it.
Upvotes: 1
Views: 249
Reputation: 785286
Translating my comment to an answer.
Problem is that you're not capturing text from regex pattern in your rules even though you're using back-reference $1
in target. You should be using:
RewriteRule ^blogs/blog/(.*)$ https://elashsupplies.com.au/blog/$1 [L,R=301,NE,NC]
RewriteRule ^blogs/blog/tagged/(.*)$ https://elashsupplies.com.au/blog/tag/$1 [L,R=301,NC,NE]
Also important is to keep these redirect rules before all other rewrite rules in your .htaccess. Consider moving these rules to Apache or virtual host config file for better performance.
Upvotes: 1