I’m trying to add some lines in my WordPress htaccess file in order to redirect some urls but no matter where I put the line I’m not getting any luck. I’ve tried testing my regex using http://www.regexr.com/ and it works fine but when I use it in the htaccess file itself nothing is happening.
The URL’s are child pages of another page (slug is /wedding-fayre-diary/) – I’d like to delete these pages (including the parent page) but redirect the URL’s to prevent 404 errors from happening.
The URL’s I’m looking to pattern match look likeâ¦
http://findyourdreamdress.co.uk/wedding-fayre-diary/gorgeous-with-curves/
http://findyourdreamdress.co.uk/wedding-fayre-diary/impression-bridal/
http://findyourdreamdress.co.uk/wedding-fayre-diary/ivory-co/
http://findyourdreamdress.co.uk/wedding-fayre-diary/ella-rosa/
I want the URL’s to redirect to a blog at this URLâ¦
http://findyourdreamdress.co.uk/blog/
Here is my htaccess codeâ¦
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteRule ^wedding-fayre-diary/(.*) /blog/ [QSA,L]
After having yet another look around I managed to find the answer – I think I was missing a couple of important flags. I changed them to [R=301,L,NC] and put the line above the standard WordPress rules and everything appears to be groovy. Here’s my finished codeâ¦
It also worth noting that you can’t add flags with the WordPress add_rewrite_rule function – it works ok for redirecting single urls but if you need to use flags like I do you’re better off editing the .htaccess file itself.