Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

  • css.mydomain.com
  • js.mydomain.com
  • img.mydomain.com

The main site URL is www.mydomain.com. 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 css.mydomain.com, js.mydomain.com, img.mydomain.com

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

1 Answer 1

You can do this by using <files>. This is explained fairly well here: http://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess.html

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: css.mydomain.com js.mydomain.com img.mydomain.com –  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.