Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

This should work:

RedirectMatch 301 ^/products/cool-tshirt$ http://yourdomain.com/tshirts$1

You can also see a bunch of other options and solutions here

Hope this helps.

share|improve this answer
    
if you review my code you can see that I want to redirect products/cool-tshirt to tshirts when I use the above code it open 404 page. –  N. Kirk May 7 at 8:38
    
Sorry I had misread the question. Edited my answer. –  mightypixel May 7 at 8:51
    
redirect alone doesn't work. It should be RewriteRule –  N. Kirk May 7 at 8:58
    
Also see this question –  mightypixel May 7 at 9:12
    
your last suggestion was ok for me. Thanks. –  N. Kirk May 7 at 10:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.