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

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

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

Edit

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 http://www.itsananderson.com/2009/01/wamp-alias-directories/ 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

1 Answer 1

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.

http://httpd.apache.org/docs/2.2/rewrite/

share|improve this answer
    
I've added line "static.company.com 127.0.0.1" to hosts and restarted machine. When I go there (http://static.company.com) it is not redirected at all. Am I doing something wrong? –  ruruskyi Aug 1 '12 at 13:15
    
What does a DNS query of "static.company.com" return? It should return 127.0.0.1. 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: 127.0.0.1 static.company.com. Good! Now I am going to configure Apache.. –  ruruskyi Aug 1 '12 at 13:29
    
Not sure this is correct: RewriteCond %{HTTP_HOST} ^static.company.com[nc] RewriteRule ^(.*)$ http://localhost/static.company.com/$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/static.company.com/multimedia ProxyPassReverse /multimedia http://localhost/static.company.com/multimedia –  ruruskyi Aug 6 '12 at 9:06

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