I am trying to redirect Image Urls to a page. I have used 301 Redirection plugin, but that doesn't seem to work.

For ex : http://mywebsite.com/wp-content/uploads/2015/02/Contestant-11.jpg should redirect to mywebsite.com/page

I have used 'Link to' to 'Media File' in individual image settings since I am using Social gallery plugin and it needs images to be linked to 'Media File' (since it is a Lightbox social sharing plugin)

How can I redirect all the image URls to a page of my choice using htaccess?

  • You'll need a .htaccess rewrite to intercept the request - your link settings in WordPress only affect where the image links to, not the actual URL of the file! Commented Feb 14, 2015 at 12:50
  • Does editing the .htaccess file in the wordpress installation do the job?
    – TheGuy
    Commented Feb 14, 2015 at 13:18
  • What do mean "in the WordPress installation"? Commented Feb 14, 2015 at 13:20
  • There is a .htaccess file in the directory Wordpress is installed.
    – TheGuy
    Commented Feb 14, 2015 at 14:38
  • Yep, that's the one. Commented Feb 14, 2015 at 15:19

1 Answer 1


You'll need to add a rewrite rule to your .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !/wp-admin/ [NC]
    RewriteRule ^wp-content/uploads/.+?\.(jpe?g|png|gif|svg)$ /my-page [R=301,L]

Add this after anything added by WordPress. You'll need to replace /my-page with the slug of the page you'd like to redirect to.

  • Thank you. That worked. But all the images on the website are broken and not being displayed.
    – TheGuy
    Commented Feb 14, 2015 at 15:58
  • Well yeah, because they redirect to the page. Commented Feb 14, 2015 at 16:31
  • Thank you for your help. Is there any way to redirect individual images to 'my-page' instead of the folder itself.
    – TheGuy
    Commented Feb 14, 2015 at 16:35
  • 1
    Yes, just use Redirect /wp-content/uploads/file.jpg /page-to-redirect-to Commented Feb 14, 2015 at 16:53
  • Thank you very much. The problem was solved. I have a pet contest website where users vote on pet photos. Users can also share the Pet photos on social networks. The problem until now was when a user shares a pet photo on Facebook, only the image was shared and not the page. So with your help, I managed to redirect the image to the pet contest page. But now, when the user shares a particular pet photo, the pet-contest page is being shared with the thumbnail of the first pet photo on the page. Can you kindly suggest a workaround for this problem.
    – TheGuy
    Commented Feb 14, 2015 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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