Bhavik Chudasama
Bhavik Chudasama

Reputation: 53

Image redirect in .htaccess

I have used the image redirect rule in .htaccess it is working but subdomain images do not show.

RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename.*$ [NC] 
RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /image_forward.php?image=$1.$2 [NC,L]

Above Rewrite condition work properly but when i open subdomain i.e.(name.sitename.com) images are not display.

Upvotes: 1

Views: 77

Answers (1)

Jon Lin
Jon Lin

Reputation: 143856

Just add your subdomain as one of the conditions:

RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.sitename [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename.*$ [NC] 
RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ /image_forward.php?image=$1.$2 [NC,L]

WHere "subdomain.sitename" is your subdomain.

Upvotes: 1

Related Questions