Jump to content

Script for redirection


Mancubus

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.