I have a script which redirects the user to a mobile subdomain like m.localhost.com if he/she access the local site on a mobile phone or tablet. Everything works fine on my PC (The place where my local website is hosted and I'm using Apache 2.4 and PHP 5.5) but when I type my ip into my mobile browser for example, it redirects me to (m.192.168.1.102) and when I type localhost.com it doesn't shows me my local website even though the host and the mobile are connected to the same network. I don't want to edit every hosts file on every device, I just want to visit the subdomain on another device rather than my PC. I know it might be a stupid question but how does the hosts like 000webhost and Ifastnet and many others redirect their users to subdomains? Thanks in advance
Asked
Active
Viewed 753 times
0
-
You are mixing up a few things. You can connect to your server from your mobile phone because you are already on the wifi network that uses the mentioned ipadres. It is an internal ip adres. When you try localhost.com your system is trying to find that domain on the internet. I doubt you own that domain. – RST Jan 22 '17 at 12:07
-
http://stackoverflow.com/questions/7404699/connecting-to-local-web-server-when-i-am-outside-my-lan – RST Jan 22 '17 at 12:11
-
Well, everything is on a local network, even the domain!! You know, you can make any domain on localhost by editing hosts and configuring your apache module. I do own a .com domain but as I said, I want it to work on a local connection and NOT ONLINE. – Hussein Mirzah Jan 22 '17 at 18:48
-
Okay, well the only way to solve it is by letting your router know where to go when you enter that domain. If your router doesn't support it then it is not possible without editing hosts file on every device. Google 'access localhost by domainname' for more details. – RST Jan 23 '17 at 12:09