I am trying to view my site on other devices, mainly mobile devices. I am using Wampserver 3.0 with apache 2.4.17. I am also using the virtual host feature built in wampserver to view my site and my code is not in the wamp64\www\ folder, instead it is in my documents folder. I have been able to allow other devices view the wampserver default page but whenever I go to my website i get "fitly's server DNS address could not be found"
Here is the httpd-vhosts.conf file
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp64/www
<Directory "C:/wamp64/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName fitly
DocumentRoot c:/users/juan/documents/fitly
<Directory "c:/users/juan/documents/fitly/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This is a solution I have used in the past. Although I admit there must be other ways, none that I have found are quicker/easier to implement.
The basic problem is of course that we cannot address our Virtual Host by name from a mobile device, even when it is wifi connected to our routers subnet, because the devices browser does not know where to find our Virtual Hosted domain name when we try and use it.
As most if not all mobile devices are locked down and assuming like me you dont want to have to jailbreak
all your test devices, we cannot take the easy option of adding our Virtual Host's name to a devices HOSTS file, which of course does exists, but we are prevented by the devices security from accessing it.
So I use Fiddler
to create a reverse proxy on the Server PC so I can use a website address like 192.168.1.10:8888
(my web server PC's ipaddress and a port number) and get Fiddler
to capture that address and convert it to http://fitly
and pass that on to Apache which will then correctly find my development Virtual Hosted site.
For this you will need to install Fiddler
which can be found here and is free
First make sure that your Virtual Hosted domain works properly on the PC running WAMPServer(Apache).
Then make these amendments to the Fiddler
config, dont worry its quite simple. Here are the instruction on how to do that on the Fiddler Site which are basically
Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked.
Click Tools > Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked.
Restart Fiddler if prompted.
Click Rules > Customize Rules.
Inside the OnBeforeRequest handler*, add a new line of code:
if ( oSession.host.ToLower() == "192.168.1.2:8888" ) {
oSession.host = "fitly";
}
192.168.1.2
being the ip address of the PC running Apache i.e. the IP Address of the PC we have installed WAMPServer(Apache) and Fiddler.
- Using the device, go to
http://192.168.1.2:8888
. Fiddler should now capture that address and forward it on to Apache using the domain name of your Virtual Host so Apache can see it and pass you to the right site, similiarly responses will be sent back to the device that made the call.
Of course you can use any port number you like it does not have to be 8888
.
You will also find Fiddler very useful for debugging many issues with your website, so dont assume its just a reverse proxy alone.