Howdy, I have to perform the following:

  • allow use of sub.domain.com/directory from www.domain.com (connecting for an resource)
  • prevent use of sub.domain.com/* (Return a 404 page when user hits subdomain directly

Is possible using htaccess and, if that's the case, any pointers regarding how to do it?

Thanks

Using .htaccess you might like to lookup htaccess and regex lessons because they are a big help.

Stop sites from hotlinking is exactly what I suppose you're mentioning to therefore: you have to enable mod_rewrite and add this towards the .htaccess file within the domain's root directory (after some of the items you learn):

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.domain.com/noHotlink.gif

This will point you within the right direction towards how to get it done.