Redirect gallery folder to a gallery in another domain

I have a wordpress blog with Nextgen gallery installed, I want to redirect all the gallery image request to another domain.I have duplicated all the images from site1 to site2 folder.

http://site1.com/wp-content/uploads/gallery/folder/*.jpg
to
http://site2.com/gallery/folder/*.jpg

Read More

please help me with the .htaccess redirect rules

Related posts

Leave a Reply

1 comment

  1. I have a wordpress blog with Nextgen gallery installed, I want to
    redirect all the gallery image request to another domain.I have
    duplicated all the images from site1 to site2 folder.

    You have to make sure the custom rules don’t get in conflict with WP own rule-set.

    Assuming it is the standard one in one .htaccess file at root directory, replace it with the following one:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    
    # Add this line
    RewriteCond %{REQUEST_URI} !wp-content/uploads/gallery/folder  [NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # Add this line
    RewriteRule ^wp-content/uploads/gallery/folder/([^.]+).jpg   http://site2.com/gallery/folder/$1.jpg [R=301,L,NC]
    
    </IfModule>
    # END WordPress
    

    Option:

    For any file type, replace the last rule with this one:

    # Add this line
    RewriteRule ^wp-content/uploads/gallery/folder/([^.]+).([^/]+)/?   http://site2.com/gallery/folder/$1.$2 [R=301,L,NC]