I'm setting up a virtual host in apache just for static files. Therefore I'd not add a php handler, which is fine.

However, is it possible to configure the virtualhost to accept only jpg, gif and png requests or at least throw 404's for any php file request?

Thanks

link|improve this question
Why can't you just remove the php module from apache? Do you have other dynamic sites you need it for? – Yitzchak Jul 21 '11 at 17:14
feedback

2 Answers

up vote 0 down vote accepted

Well .. try this (you will need mod_rewrite enabled):

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} =static.example.com
RewriteRule ^(.*)\.php - [NC,F,L]

This will block (403 error) all requests to .php files if domain name = static.example.com. If you do not like 403 error -- replace [F] flag by [R=404].

link|improve this answer
feedback

Yes - there's lots of ways of doing it. But why do you need to return a 404 response if it tries to

1) access a file which should not exist on the server in the first place

2) has no handler

?

link|improve this answer
I'm trying to set up a seperate domain for my static files, pointing to the same docroot directory as my main domain. This only to avoid cookies being sent for statics – Steven De Groote Jul 21 '11 at 16:45
feedback

Your Answer

 
or
required, but never shown

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