To redirect a url from having specific string to aonther url in wordpress

I have to redirect url in my site to single url. Means if any go to http://www.example.com/blog/photos/IMG_5867_2-tm.jpg, He should go to the particulate url i gave. e.g. ( http://www.example.com/blog/wp-content/uploads/2015/08/common.png )

I have followed some answers in the previous question from Stackoverflow. But it is not working for me. I have tried like this.

Read More
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewriterule ^blog/photos/(.*)$ exampe.com//blog/wp-content/uploads/2015/08/common.png$1 [r=301,nc]
RewriteRule . /blog/index.php [L]

</IfModule>

Is there anything wrong i have done. Please help and advance thanks.

Related posts

1 comment

  1. You can use:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    
    Rewriterule ^photos/.+$ wp-content/uploads/2015/08/common.png [R=301,L,NC]
    
    RewriteRule ^index.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    
    </IfModule>
    

    If your .htaccess is placed in /blog/ directory then RewriteRule will match URI pattern after /blog/

Comments are closed.