Reputation: 103
I am new to WordPress and I have uploaded my files into two domains, a main domain and a sub domain. In my sub domain I want to show my main domain images by htaccess. I have used below codes but couldnot get any success.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(files/profile_image/.*)$ http://example.com/$1 [R=301,NC,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://dev.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [NE,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
I have used above code but couldn't get any success. Can I get any help?
Upvotes: 1
Views: 904
Reputation: 4204
I know this is old, but posting an alternative simple method here:
RedirectMatch 301 /wp-content/uploads/(.*) https://live-site-to-redirect-from.com/wp-content/uploads/$1
Upvotes: 1
Reputation: 4243
I do this all the time with my localhost sites to grab the images from the online production site. In your sub domain .htaccess file use the following.
<IfModule mod_rewrite.c>
# Attempt to load files from production if
# they're not in our dev version
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*) \
http://example.com/wp-content/uploads/$1 [NC,L]
</IfModule>
Upvotes: 0