Forum Moderators: phranque
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
RewriteCond $1 !old-site/
RewriteRule ^(.*\.php)$ /old-site/$1 [L]
RewriteCond $1 !site-offline\.html$
RewriteRule ^(.*\.php)$ http://www.example.com/site-offline.html [R=302,L]
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
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.
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
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.
Alternatively, add another IP exclusion specifying the IP address of your server, so that it can access itself via HTTP.
Jim