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

Re: Redirect all http requests to a single page?



On Tue, 2004-09-14 at 07:06, Frederik Dannemare wrote:
> -----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.
> >
> 
> 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.


I don't even think you have to get that fancy. Use the RedirectMatch
runtime Apache configuration directive. 

http://httpd.apache.org/docs-2.0/mod/mod_alias.html#redirectmatch

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: