I need some .htaccess advice. Can anyone help?
I need to take a site offline for a major upgrade, but want to be able
to surf to it myself to check progress etc. So should I use
the .htaccess file to block everyone except my IP address? Is this
the best way to do it, or is there an alternative?
To complicate things further I need to set the server/site to return a
503 status. Can this be done in the .htaccess file?
so many questions, so little time
You might want to think about not using a 503 and using a 302 instead,
and redirecting to a "maintenance" page. That way, users will know what
is going on instead of getting a confusing 503 error message.
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
1) create a sub domain with a document root *next* to the current one
(say htdocs-new next to htdocs)
2) install the site in the directory for the subdomain
3) test
4) mv htdocs htdocs-old
5) mv htdocs-new htdocs
(if you use a database and want to upgrade that as well it gets a bit more
complicated)
--
John Bokma http://johnbokma.com/
AISE/AWW/SEO/web development forum: http://seo-expert-wiki.com/
thanks John, that is the main problem, it has database, email
connections and absolute paths in the links, plus a back end CMS style
interface. I'll have a look though and see what I can do.
The main reason for the 503 is for Google and other search engine
bots, telling them that the site is under maintenance and to come back
later, instead of them indexing the "under construction" page and
dropping all the others.
small mouse wrote:
>The main reason for the 503 is for Google and other search engine
>bots, telling them that the site is under maintenance and to come back
>later, instead of them indexing the "under construction" page and
>dropping all the others.
That is the advice given in the Google Webmaster Central Blog at
[ http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.html ]
where it says:
Q: "If my site is down for maintenance, how can I tell
Googlebot to come back later rather than to index
the "down for maintenance" page?
A: "You should configure your server to return a status
of 503 (network unavailable) rather than 200 (successful).
That lets Googlebot know to try the pages again later."
The exact meaning of the 503 response code is found in
RFC 2068 [ http://www.faqs.org/rfcs/rfc2068.html ]:
503 Service Unavailable
The server is currently unable to handle the request due to a
temporary overloading or maintenance of the server. The implication
is that this is a temporary condition which will be alleviated after
some delay. If known, the length of the delay may be indicated in a
Retry-After header. If no Retry-After is given, the client SHOULD
handle the response as it would for a 500 response.
Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.
BTW, the users will not see any "Under Construction" page that
you create. Only status codes between 300 and 399 redirect to
another URL. They will see the standard 503 page from your
server. Usually this will be
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Temporarily Unavailable</title>
</head><body>
<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
</body></html>
One of the best resources for understanding http
responses is here:
[ http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html ]
BTW, are you planning on sending a Retry-After header?
--
Guy Macon <http://www.GuyMacon.com/> Guy Macon <http://www.GuyMacon.com/>
Guy Macon <http://www.GuyMacon.com/> Guy Macon <http://www.GuyMacon.com/>
Guy Macon <http://www.GuyMacon.com/> Guy Macon <http://www.GuyMacon.com/>
Guy Macon <http://www.GuyMacon.com/> Guy Macon <http://www.GuyMacon.com/>
That's great, I didn't know about the retry-after header, I'll look
into it. By the way, can you do this in the .htaccess file or is it a
server configuration thing?
That site is superb (http://www.askapache.com) i have found this
(below) which seems to serve my purpose, i.e. send everything a 503
except the IP number specified. I don't quite understand what the last
two lines do, does this require extra configuration in the cgi-bin
folder?
Can I add the retry line at the end as below?
-------------------------------------------------------------
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
RewriteCond %{REQUEST_URI} !^/cgi-bin/error/503\.php [NC]
RewriteRule .* /cgi-bin/error/503.php
-------------------------------------------------------------
Retry-After: Fri, 31 Dec 1999 23:59:59 GMT