Mancubus Posted August 12, 2012 Share Posted August 12, 2012 Hello guys. I need some help to so solve my puzzle. I have a website hosted on a free hosting, but I'm also running the same site on my PC, using OpenServer. The question is, how to redirect my visitors from the free host to my PC when it is on? As you understand, when it is off, visitors shall see the content from the free host. I mean, I need to load from my PC even if host is working, but if PC is turned off, then it acts regular, loading index from host corner. I need a script to do this? How exactly? Thanks! Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 12, 2012 Share Posted August 12, 2012 My recommendation would be to just keep the site in one location, as DNS servers can take quite a lot of time to update properly. Doing this is just giving yourself, and your visitors, a completely unnecessary headache. Quote Link to comment Share on other sites More sharing options...
Mancubus Posted August 12, 2012 Author Share Posted August 12, 2012 Why DNS? I've been told that there is a possibility to write a script using this parameters: fsockopen, curl, file_get_contents, fopen I need to load from my PC even if host is working, but if PC is turned off, then it acts regular, loading index from host corner. Quote Link to comment Share on other sites More sharing options...
xyph Posted August 12, 2012 Share Posted August 12, 2012 Does your free host allow a CRON job to be created? If you want to check if your home computer is up before serving content, the user will have to wait for that connection attempt to either time out (causing a delay on every page load) or you'll have to keep track of when your site is up/down using a script. A CRON job is ideal. It could run every minute, and if your site was up it would set some sort of flag that you could check against. You'd still have to create a fall-back, in the event that your site went down in between the 1 minute intervals. Without access to that, you could emulate a CRON with PHP. There are many examples of how to do this on the web. By only requiring it to check your home PC every minute (assuming it's offline) you save the user from the check on each request. Hope that helps. 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.