Redirect All Requests to a Single Page
I found this little tidbit useful. I guess it's not that hard to figure out yourself, but it might make a nice FAQ. Basically, in the midst of moving some of my server stuff over to Slicehost, I knew my web server wouldn't be able to respond for a few minutes, so I wanted to put a reasonable looking "Sorry, we'll be back soon" message, rather than just letting it fail. On a Debian or Ubuntu system, this ought to be enough:
In the /etc/apache2/apache2.conf file, the last line looks like so:
Include /etc/apache2/sites-enabled/
Comment it out, and put this in instead:
#Include /etc/apache2/sites-enabled/
AliasMatch .* /var/www/backsoon.html
All it takes is an /etc/init.d/apache2 reload to make the change take effect, and another one once you're up and running again.
Trackbacks
Use the following link to trackback from your own site:
http://journal.dedasys.com/trackbacks?article_id=1927
28 minutes later:
I've always preferred this approach:
That way to take the site down you just create a basic HTML page and save it to /tmp/down.html - if it exists it is served for all visitors. If it doesn't then it isn't.
(Of course there is going to be the overhead of a single stat() for each incoming request; and it doesn't make sense if you're not already using
mod_rewrite.)about 2 hours later:
If you care about search engine indexing, you might want to consider 302'ing instead than serving a page that might pollute your results. Even better, serve the page with a 307 code.
about 3 hours later:
Search engines are one thing to care about - but probably only if your site is "offline" for a significant period of time.
Another thing that you might consider important, and could overlook, is what happens when RSS readers attempt to read a feed hosted on your site and get back plain HTML instead ..
about 7 hours later:
Good points. It would be nice to come up with some sort of 'definitive' recipe for this and post to to the Apache docs, or somewhere else appropriate.