Forum Moderators: phranque

Message Too Old, No Replies

Temporary site take down?

for updates

         

norbiu

1:05 am on Apr 5, 2007 (gmt 0)

10+ Year Member



I need to take down my site for a few hours to make some updates. I don't want the users to see all the mess. Is there a way to take it down with htaccess so that every page they access becomes unavailable, but without asking for a password or something, just a page telling them about what's going on. Thanks!

jdMorgan

1:22 am on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your site dynamic?

If not, then you can rewrite -not redirect- all requests to an old copy of your site in a subdirectory. When the update is done, you remove the rewrite, and the site updates "instantly" with no loss of service whatsoever.

In order to answer your original question, it'll be necessary for us to know what the filetypes of your pages are, for example, .html, .php, etc.

Jim

norbiu

1:41 am on Apr 5, 2007 (gmt 0)

10+ Year Member



The site is static and all pages are .php

jdMorgan

2:09 am on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In that case, you could rewrite all .php pages to a temporary copy of the site's php pages in a subdirectory called "/old-site" using

RewriteCond $1 !old-site/
RewriteRule ^(.*\.php)$ /old-site/$1 [L]

As a distant second-choice, you could redirect all php pages to one "Site is temporarily offline" page using:

RewriteCond $1 !site-offline\.html$
RewriteRule ^(.*\.php)$ http://www.example.com/site-offline.html [R=302,L]

In both cases, the RewriteCond is used to prevent a loop, and the code is written for use in your root .htaccess file.

The first solution provides a seamless update; The site updates "instantly" when you remove the rule, and it will have zero impact or risk with the search engines.

Jim

norbiu

1:41 pm on Apr 5, 2007 (gmt 0)

10+ Year Member



Thanks Jim! I tried adding a

RewriteCond %{REMOTE_HOST}!^my\.ip\.add\.ress

to the second code to make it ignore my ip, but it looks like it's interfering with the site-offline.html page. The whole code from that page is included in every other page of the site I visit.

Also, the php include command doesn't work. I must have missed something.

jdMorgan

2:49 pm on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Also, the php include command doesn't work. I must have missed something.

That's why I specified an ".html" file for the site-offline page. It should be a stand-alone page, no includes except for maybe your logo image. Anything else included on that page must not be changed as part of your "site update" which is why you want it to be a simple, static page with very few or no dependencies on the rest of the site.

The possibilities for what you might mean by "site update" are endless; so this is the safest approach. For example, by using a static .html page, you avoid problems, even if you upgrade the version of PHP you're using. That's because the static .html page doesn't use PHP.

As far as your trouble with adding the REMOTE_HOST check, the obvious problem is that you need to use %{REMOTE_ADDR} to match an IP address. REMOTE_HOST is the reverse-DNS hostname of your computer, most probably identifying only your ISP and your "customer number". Also, most servers run with rDNS disabled, since it requires so many outgoing connections to the DNS system and slows things down so much (Every incoming client HTTP request results in an outgoing reverse-DNS lookup request, and the incoming client HTTP request must wait for the rDNS lookup to complete before proceeding).

Jim

norbiu

3:14 pm on Apr 5, 2007 (gmt 0)

10+ Year Member



I think you misunderstood. I'm using the php include command on my site to add things like a sidebar, footer, etc without having to modify every page in case I need to make a change.

After I use the REMOTE_ADDR command, I can get in the site, but things that should be included are missing and the text I put in the site-offline.html is all over the place.

I viewed my source and I noticed that instead of including the sidebar and footer, it includes the site-offline.html page.

jdMorgan

4:16 pm on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds like you are using an HTTP GET to include objects in your PHP pages. Since you've ignored my advice to keep your site-offline page as a simple .html page with no external dependencies, I suggest you simply use local-filesytem includes instead of HTTP-GET includes, as this is MUCH more efficient -- at least 1000% more efficient.

Alternatively, add another IP exclusion specifying the IP address of your server, so that it can access itself via HTTP.

Jim

norbiu

5:38 pm on Apr 5, 2007 (gmt 0)

10+ Year Member



My "site offline" page is an html page.

I added the second exclusion and everything works great! Thanks again.