You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Steve Finkelstein <sf...@stevefink.net> on 2007/08/30 17:45:05 UTC

[users@httpd] ErrorDocument 404 redirect with server response code issue

Hi all,

I'm trying to redirect users to my base URL upon a 404 submission. According
to Apache's documentation, the method I'm using is not sufficient:

Note that when you specify an ErrorDocument that points to a remote URL (ie.
anything with a method such as http in front of it), Apache will send a
redirect to the client to tell it where to find the document, even if the
document ends up being on the same server. This has several implications,
the most important being that the client will not receive the original error
status code, but instead will receive a redirect status code.

I'd send like use proper headers, send a 404 to the client, then redirect
them to my base URL.

Is this possible? Should I resort to mod_rewrite versus ErrorDocument?

Thanks,

- sf

Re: [users@httpd] ErrorDocument 404 redirect with server response code issue

Posted by Steve Finkelstein <sf...@stevefink.net>.
Thanks all, makes more sense now. :-)

- sf

On 8/30/07, Joshua Slive <jo...@slive.ca> wrote:
>
> On 8/30/07, Steve Finkelstein <sf...@stevefink.net> wrote:
> > Hi all,
> >
> > I'm trying to redirect users to my base URL upon a 404 submission.
> According
> > to Apache's documentation, the method I'm using is not sufficient:
> >
> > Note that when you specify an ErrorDocument that points to a remote URL
> (ie.
> > anything with a method such as http in front of it), Apache will send a
> > redirect to the client to tell it where to find the document, even if
> the
> > document ends up being on the same server. This has several
> implications,
> > the most important being that the client will not receive the original
> error
> > status code, but instead will receive a redirect status code.
> >
> > I'd send like use proper headers, send a 404 to the client, then
> redirect
> > them to my base URL.
> >
> > Is this possible? Should I resort to mod_rewrite versus ErrorDocument?
>
> No, it's not possible. This is just the way HTTP works. You either get
> an error code (404) or you get a redirect code (30x), you can have
> both.
>
> As a design issue, I suggest making a proper 404 page and simply
> providing an obvious link on this page back to your home page. This is
> clearer both for real users and for robots.
>
> If you really want to, you can create a 404 error page that uses a
> <meta> refresh in the html to take you back to the homepage. But this
> would be ugly and annoying.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] ErrorDocument 404 redirect with server response code issue

Posted by Joshua Slive <jo...@slive.ca>.
On 8/30/07, Steve Finkelstein <sf...@stevefink.net> wrote:
> Hi all,
>
> I'm trying to redirect users to my base URL upon a 404 submission. According
> to Apache's documentation, the method I'm using is not sufficient:
>
> Note that when you specify an ErrorDocument that points to a remote URL (ie.
> anything with a method such as http in front of it), Apache will send a
> redirect to the client to tell it where to find the document, even if the
> document ends up being on the same server. This has several implications,
> the most important being that the client will not receive the original error
> status code, but instead will receive a redirect status code.
>
> I'd send like use proper headers, send a 404 to the client, then redirect
> them to my base URL.
>
> Is this possible? Should I resort to mod_rewrite versus ErrorDocument?

No, it's not possible. This is just the way HTTP works. You either get
an error code (404) or you get a redirect code (30x), you can have
both.

As a design issue, I suggest making a proper 404 page and simply
providing an obvious link on this page back to your home page. This is
clearer both for real users and for robots.

If you really want to, you can create a 404 error page that uses a
<meta> refresh in the html to take you back to the homepage. But this
would be ugly and annoying.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] ErrorDocument 404 redirect with server response code issue

Posted by Bj <bj...@gmail.com>.
Why don't you use an 404 html page with an automatique redirection to your
home ?

-- 
Bj

On 8/30/07, Jeff Peng <je...@gmx.net> wrote:
>
>
> -------- Original-Nachricht --------
> > Datum: Thu, 30 Aug 2007 11:45:05 -0400
> > Von: "Steve Finkelstein" <sf...@stevefink.net>
> > An: users@httpd.apache.org
>
> > I'd send like use proper headers, send a 404 to the client, then
> redirect
> > them to my base URL.
> >
> > Is this possible? Should I resort to mod_rewrite versus ErrorDocument?
> >
>
>
> I don't think it's possible.Once you send 404,you don't have chance to
> send 30x for redirection again.
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] ErrorDocument 404 redirect with server response code issue

Posted by Jeff Peng <je...@gmx.net>.
-------- Original-Nachricht --------
> Datum: Thu, 30 Aug 2007 11:45:05 -0400
> Von: "Steve Finkelstein" <sf...@stevefink.net>
> An: users@httpd.apache.org

> I'd send like use proper headers, send a 404 to the client, then redirect
> them to my base URL.
> 
> Is this possible? Should I resort to mod_rewrite versus ErrorDocument?
> 


I don't think it's possible.Once you send 404,you don't have chance to send 30x for redirection again.
-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org