You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by Joshua Slive <jo...@slive.ca> on 2003/01/26 17:28:25 UTC

Re: [users@httpd] Redirection



On Sun, 26 Jan 2003, Andrea Rossignoli wrote:

> Hi,
> the manual gives this example:
>
> http://httpd.apache.org/docs/urlmapping.html#redirect
>
> ----
> Alternatively, to temporarily redirect all pages on a site to one particular
> page, use the following:
>
> RedirectMatch temp .* http://www.example.com/startpage.html
> ----
>
> If example.com is the same server where that directive is put then it will
> create an infinite request loop.

Yes, the example is a little imprecise.  To be clear, it should say "...
one particular page on another site..." and the directive should use
http://othersite.example.com/startpage.html.

> I tried it on my windows pc and I put that directive inside an .htaccess,
> the result is an infinite request loop.
>
> In fact when the browser will ask for /startpage.html (because it was
> redirected to) the rule .* matches it again.

You can do this, but it requires mod_rewrite.  Something like (untested)

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/startpage.html$
RewriteRule .* http://www.example.com/startpage.html

Alternatively, you can always point the DocumentRoot at a directory
containing only startpage.html, turn off Indexes, and use
ErrorDocument 404 http://www.example.com/startpage.html

Come to think of it, it may also be possible in 2.0 to use a fancy PCRE
regex with the RedirectMatch to get it.  But you'll have to find more of a
PCRE expert or dig into the PCRE manual to come up with that.

Joshua.

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org