I have a slight problem. I am using a website in PHP to call a webpage on my host site on Host Gator. The problem is that the URL points to my own IP address and is port forwarded to a specific PC on my LAN. It works perfectly unless it is me that is trying to access the webpage. I have to use the local IP address to access the same results that others can see. There is nothing I can do within my network, I am using Comcast Business with a static IP, when using my WAN IP address it simply doesn't leave the LAN and reflect back to the WAN IP. So I was thinking of a couple of solutions:
One would be to use javascript or something to detect the requesting IP address, if the address is mine, it changes the URL to my local IP instead. That I do not know how to do. The second choice was to use PHP on the hosted website to gather the results using:
$homepage = file_get_contents('http://MYWANURL);
echo $homepage;
Where MYWANURL my URL that can be accessed from the internet. The problem is this code comes back empty. I have never had problems using file_get_contents to get other websites from my host company. If I use the same code when I am in my lan, using my lan address on a local php server, the output I am looking for works perfectly.
So my question is, is there a way via javascript OR PHP on my hosted company that I can use so that I can see the same results as people outside my LAN?
Not sure if I understood your problem correctly, but I have the following setup (Ubuntu, in /etc/hosts
)
127.0.0.1 yourhost.com
This way the packets will never leave your computer and will be immediately redirected to the named interface. Though, you have to port the same change to all hosts in your LAN if this is a problem with your router (or update your local DNS server if you use one)