Question

I have been working on a drupal test site for a while, which has a bunch of virtual hosts set up like this:

<VirtualHost *:80>
ServerAdmin email@example.com
DocumentRoot "/path/to/root"
ServerName testsite1.example.com
</VirtualHost>

I have been using a modified host file to view each of these test sites, along the lines of:

12.0.0.1 localhost
20.02.2.22 testsite1.example.com
20.02.2.22 testsite2.example.com
20.02.2.22 testsite3.example.com

This has worked fine, however now I need to send the sites over to some people remotely who are not technical enough to modify their own host files and see it the way I do.

Is there a way I could set up Apache so that the url "http://20.02.2.22/testsite1" would forward to testsite1.example.com internally? I am using Drupal, and the site setup needs to see the "testsite1.example.com" so that it can correctly choose the instance to select. I have been looking through apache rewrite, but I am a bit of a newb at this so any help is much appreciated.

Was it helpful?

Solution

testsite1.example.com will only be resolved on your machine, so you cannot redirect. You can set up proxy with mod_proxy. Hope this works for you:

<VirtualHost *:80>
  ServerAdmin email@example.com
  DocumentRoot "/path/to/root"
  ServerName testsite1.example.com
  ServerAlias 20.02.2.22
  <Location /testsite1/>
    ProxyPass http://testsite1.example.com/ 
  </Location>
</VirtualHost>

OTHER TIPS

The way I show my local test sites is a combination of Dynamic DNS and port-forwarding.

Internally, my Drupal site is at [my machine ip] or localhost.

I setup a free dynamic dns name to my IP and then on my router, accept incoming requests on port to route to [my machine ip]

That way, they can see yoursite.dyndns.com, but its looking at your local copy.

Why you just don't buy a new domain name and point it to your server IP address... Or there are free domain solutions like:

http://www.dot.tk/en/index.html?lang=en
or
http://dyn.com/dns/

If you wanna buy new domain, i recommending you this one, cheap and quality service: http://server2.elite7hackers.us/recommend.php?site=godaddy

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top