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

How to redirect subdomain locally on my computer without modifying the code?

Let's say, subdomain '' should be redirected to 'localhost/static'.


I forgot to mention that I had WAMP installed. WAMP already have 'alias directories' that do exactly what I needed - redirect URI to the folder on local server. There is a command-line interface where you should set URI (in my case, multimedia) and /path/to/the/folder/on/the/server/.

You can find this post useful also if your URI doesn't have slash(/) at the end.

share|improve this question

closed as not a real question by womble, HopelessN00b, Ward, Michael Hampton, Ladadadada Sep 11 '12 at 11:12

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

/etc/hosts file plus a little Apache configuration. – ceejayoz Aug 1 '12 at 12:47
up vote 0 down vote accepted

You would either need an entry on your local DNS server or an entry in your machine's host file to point to itself.

As for Apache you could simply setup a mod_rewrite rule to transform the URL when it comes in.

share|improve this answer
I've added line "" to hosts and restarted machine. When I go there ( it is not redirected at all. Am I doing something wrong? – ruruskyi Aug 1 '12 at 13:15
What does a DNS query of "" return? It should return You still have to make Apache changes that I mentioned to get Apache to serve the right resource. – Brent Pabst Aug 1 '12 at 13:18
should be reversed like so: Good! Now I am going to configure Apache.. – ruruskyi Aug 1 '12 at 13:29
Not sure this is correct: RewriteCond %{HTTP_HOST} ^[nc] RewriteRule ^(.*)$ http://localhost/$1 [r=301,nc] – ruruskyi Aug 1 '12 at 13:33
This two lines should be added to the server configuration (not to .htaccess) ProxyPass /multimedia http://localhost/ ProxyPassReverse /multimedia http://localhost/ – ruruskyi Aug 6 '12 at 9:06

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