Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Possible Duplicate:
Apache redirect to another domain all URLs, except for ones starting with substring

I would like to optimize image loading for my website using multiple subdomains for the static files residing in /files. Is there a good way to achieve this? I wouldn't want multiple copies of my files on the disk. Also I am looking for a simple solution that doesn't involve having to install proxies and stuff.

I got my answer here: Apache redirect to another domain all URLs, except for ones starting with substring

Thank you all for your help.

share|improve this question

marked as duplicate by Shane Madden, Iain, mailq, Sam Sep 26 '11 at 17:45

This question was marked as an exact duplicate of an existing question.

So... create a subdomain in your webserver config which loads from the same folder. – TessellatingHeckler Sep 25 '11 at 20:53

You should just be able to create other name-based virtual domains that point at the same document root, and set up the new names in DNS, and you can use these other names to your heart's content. If your current domain is not set up for name-based virtual domains, you will probably need to enable that before you can do this. If you are using IP-based virtual domains, then you shouldn't need any change at all. The virtual domains only really applies if you are hosting multiple sites each with different content.

If you really want to go wild you could set up a wild-card DNS record, and configure this domain to be the "default" name-based virtual so you could just use any random name, without having to change the server config, but I'd recommend against that. It's likely to lead to more pain than gain.

share|improve this answer
Thanks for your answer. I've already done that, but now all my URLs are duplicated, I would only like to duplicate the ones starting with /files. All the others should redirect to the main domain. The answer here… helped me, but I think I should add another condition to prevent infinite redirection for the main domain. – bogdanvursu Sep 26 '11 at 7:55
You'll want to set up a second Virtual host for those, then, and have a set of rewrite rules that redirect to the main host for anything other than /files/, should work just fine. – Sean Reifschneider Sep 28 '11 at 3:45

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