[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Redirect all http requests to a single page?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 14 September 2004 03:13, Jimmy Liang wrote:
> Hi All,
>
> I have a Sarge server running only Apache2 and not much else. All it
> does is serving 1 index.html, with a few images and css. Its my
> maintanience page for when the actual web servers are down.
> My question is, how can I make it so that any request made to the
> server, will be redirected to index.html?
> I don't care what the web users request it, I don't want any page not
> found errors, just my maintainence page.
>
> any help would be greatly appreciated.
> Thanks.
>
>
> -Jimmy

Enable mod_rewrite (if it's not already):
cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load .

Then add somethign like this to your sites-available/default:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteLogLevel 9
    RewriteLog /tmp/rewrite.log
    RewriteCond %{REQUEST_URI} !^/(index.html)$
    RewriteCond %{REQUEST_URI} !^/(picture1.jpg)$
    RewriteCond %{REQUEST_URI} !^/(picture2.jpg)$
    RewriteCond %{REQUEST_URI} !^/(stylesheet.css)$
    RewriteRule ^.+$ http://your.apache.box/index.html [R,L]
</IfModule>

Restart Apache...

Disable RewriteLog (or certainly lower RewriteLogLevel) when you have 
things the way you want them. Otherwise, the log file will grow really 
big in no time.

Read more about mod_rewrite at 
<http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html>. It's a rather 
complex module that can do all sorts of rewriting.
- -- 
Frederik Dannemare | mailto:frederik@dannemare.net
http://qa.debian.org/developer.php?login=Frederik+Dannemare
http://frederik.dannemare.net | http://www.linuxworlddomination.dk
Key fingerprint: BB7B 078A 0DBF 7663 180A  F84A 2D25 FAD5 9C4E B5A8
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBRvsCLSX61ZxOtagRAtHKAJ9GttlERICjWPaLxsjeQBTU8s7i6wCggc2i
wTduPcIy8D/x9kAAYl6p+Bg=
=Tb1J
-----END PGP SIGNATURE-----



Reply to: