Take Website Off Line

zardiw

Perch
Is there an easy way to take a website off line for a few minutes.....and restrict it to only one IP address for those few minutes?

I guess .htaccess would work......just wondering if there's another way.......z
 
I'm thinking of having 2 different .htaccess files and FTPing them depending on if the site is to be off/on line.......any other thoughts.......z
 
you can in the hsphere CP set the website to 'disabled' for www service, it won't allow anyone to access it however. I think this can be done with htaccess as well but writing such rules is not something I know :(
 
I think it might be something like:

<Files *>
order allow,deny
deny from all
allow from 100.100.100.100
</Files>

Tim
 
Are you running a dynamic site (php)? If you have a consistent header file included at the top of every file, you could do a redirect to a "sorry we're offline" page. You could use php to detect the IP and send everyone to that page except you. It'd be friendlier than giving everyone an ugly apache error page.

Tim
 
Are you running a dynamic site (php)? If you have a consistent header file included at the top of every file, you could do a redirect to a "sorry we're offline" page. You could use php to detect the IP and send everyone to that page except you. It'd be friendlier than giving everyone an ugly apache error page.

Tim


That sounds viable. Actually there's only one page that would need to be redirected. I could have a separate webpage where I could set the on/off line somehow.

The reason I'm thinking of this is that I recreate the database for my website every nite.......and I was worried that people using the database while I'm creating it would mess it up or something.

It's a MySql database.............z
 
Maybe have an include file that has the header line in it......and change that include file with another PHP page to set a flag in a little file in the cgi-bin.......z
 
How do you re-create the database? Restore from an SQL file via a script? If so, my guess is that it happens quickly enough that no one would notice.

You could set a flag in the database that says the update is in process...then have your output pages check that flag and either show the page or a "site's down" page. Your DB re-creation script could set the flag at the start/end. That would require an extra query on every request but would let you completely automate the process.

Tim
 
Actually, I build part of the database every nite. It's a read only for the most part. There's 4 tables. 2 of them get built from scratch every nite, then one of them gets updated from the 3rd one. It takes about 20 clock seconds to build the biggest one.....z
 
PS. It hasn't seemed to affect anything.......but then there's not that many users yet......maybe MySql is smart enough to handle it without doing anything........z
 
Could you build to a temporary table instead of the live table? You could then drop the main table and rename the alternate table. Or, you could keep both and have your script update a config file to point to the current one (alternate back and forth each day between the two tables). Those sorts of switches would be on the order of milliseconds.

Tim
 
Back
Top