Michael Daly Posted February 11, 2007 Share Posted February 11, 2007 I have two virtual hosts on a single Apache 2.2 web server. I also have two machines as: 1 - Production. 192.168.123.1 - firewall routes real traffic to this one with domain names e.g. realdomain.foo/bunch/of/stuff. I can't touch this server. 2 - Test. 192.168.123.2 - I test on this. The test machine gets web accesses in the form of 192.168.123.2/bunch/of/stuff. Since I need to do rewrite processing on the [HTTP_HOST], I'm not getting the domain, just the IP. How do I spoof the test server so that the rewrite can be tested with realdomain.foo/bunch/of/stuff instead of 192.168.123.2/bunch/of/stuff? Quote Link to comment Share on other sites More sharing options...
Michael Daly Posted February 19, 2007 Author Share Posted February 19, 2007 I figured out a solution that seems to work (so far). In the virtual host rewriting section, I start with: # Do nothing rewrite rule that sets the environment variable. RewriteRule .* - [E=USE_HOST:realdomain.foo] ... bunch of stuff ... # Test the host and rewrite accordingly RewriteCond %{ENV:USE_HOST} ^realdomain\.foo$ [NC] This lets me use the faked host instead of the IP for testing on the LAN. When I want to do final test (and move code to production) in a production level environment, I change the first rewriterule to: RewriteRule .* - [E=USE_HOST:%{HTTP_HOST}] Now I have the same code with the host as it comes in from the 'net without touching the rest of the code (and inadvertently breaking it). Not perfect, but acceptable for now. Quote Link to comment Share on other sites More sharing options...
Michael Daly Posted February 21, 2007 Author Share Posted February 21, 2007 And a better solution still is to edit the "hosts" file (\WINDOWS\system32\drivers\etc\hosts - no extension) and put the domain in with the LAN address. Windows uses HOSTS as a kind of DNS cache. Just make sure you remove the entry from hosts when you're done or you'll never get the real IP. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.