homepage Welcome to WebmasterWorld Guest from 54.145.238.55
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Block file from accessing using .htaccess for a subdomain
TechMan

5+ Year Member



 
Msg#: 4267800 posted 7:46 am on Feb 16, 2011 (gmt 0)

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

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4267800 posted 8:27 am on Feb 16, 2011 (gmt 0)

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.

jdMorgan

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



 
Msg#: 4267800 posted 3:14 am on Feb 18, 2011 (gmt 0)


RewriteCond %{HTTP_HOST} =test.domain.com
RewriteRule ^test\.jpg$ - [F]

TechMan

5+ Year Member



 
Msg#: 4267800 posted 3:54 am on Feb 18, 2011 (gmt 0)

Yes this worked.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved