How can I redirect non existent pages/posts in WordPress using only .htaccess file?
Here is my code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^products/cool-tshirt$ /tshirts [R=301,L]
</IfModule>
Thank you in advance.
How can I redirect non existent pages/posts in WordPress using only .htaccess file?
Here is my code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^products/cool-tshirt$ /tshirts [R=301,L]
</IfModule>
Thank you in advance.
Share Improve this question asked May 7, 2014 at 8:02 NorotiNoroti 11 silver badge1 bronze badge 2 |1 Answer
Reset to default 1This should work:
RedirectMatch 301 ^/products/cool-tshirt$ http://yourdomain/tshirts$1
You can also see a bunch of other options and solutions here
Hope this helps.
RewriteRule
directive above should already do what you require. If it's not working then you've probably put in in the wrong place - this redirect needs to go at the top of the.htaccess
file, before the WordPress front-controller. If you are not using WP's permalinks (in which case you may not have WP front-controller in.htaccess
) then make sure that mod_rewrite is enabled on your server. – MrWhite Commented May 24, 2018 at 11:34