Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The idea is to serve js,css, img files using different domains so I created following domains:


The main site URL is When I access the site throw main URL every img,css,js files are delivered to user throw subodomains. And that everything works fine.

PROBLEM IS that I can access main site using one of domains,,

AND I want is to deny every request that is not js, css, img file type.

How can I do this over htaccess?

share|improve this question

You can do this by using <files>. This is explained fairly well here:

You can first deny everything and then allow just those file types you want.

share|improve this answer
Thanks for replay. How to do this only for this domains: – Danilo Nov 8 '12 at 16:10
The easiest thing to do is put it in the .htaccess file in the directory that corresponds with each subdomain. – Ynhockey Nov 10 '12 at 19:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.