Welcome to WebmasterWorld Guest from 54.197.171.28

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Block file from accessing using .htaccess for a subdomain

   
7:46 am on Feb 16, 2011 (gmt 0)

5+ Year Member



Hi,

I have a website for e.g.

www.domain.com

And I have another subdomain for e.g.

test.domain.com

Both my main and subdomain point to same directory which is public_html.

I want to block access to

test.domain.com/test.jpg

but not

domain.com/test.jpg

Please note that this test.jpg is same file for both main and subdomain as they both point to same directory. So how do I block it for subdomain but not for main domain using .htaccess? Or is there any other way of doing that?

Thanks
8:27 am on Feb 16, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Use a RewriteCond testing HTTP_HOST.

Use a RewriteRule to test the requested path. Use the [F] flag to send the HTTP 403 response code.
3:14 am on Feb 18, 2011 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member




RewriteCond %{HTTP_HOST} =test.domain.com
RewriteRule ^test\.jpg$ - [F]
3:54 am on Feb 18, 2011 (gmt 0)

5+ Year Member



Yes this worked.