You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Andrew Hole <an...@gmail.com> on 2009/08/26 13:23:39 UTC

[users@httpd] Handling 404 errors

Hi guys!

Actually our web application has a retry mechanism based on http status code
returned to client. Just an example:
- An http request is made to http://web/software_A_folder/file.swf
- if the file doesn't exist (http 404) on software_A_folder, the request is
made in core folder: http://web/core/file.swf

This mechanism is used on entire application: when a file doesn't exist on
software_x_folder, a retry is made on core folder.

In terms of Apache, this mechanism make always 2 requests (in case of file
not found).

What I want to know is if there are any option on Apache to handle 404
status code without retry the request. When file not found, some logic will
handle the 404 and return the file located on other folder.

I appreciate your help.

Best Regards,
A.

Re: [users@httpd] Handling 404 errors

Posted by Tom Evans <te...@googlemail.com>.
On Wed, 2009-08-26 at 15:23 +0100, Andrew Hole wrote:
> Your solutions looks very useful, but i'm afraid about impact on
> server performance.
> 
> Do you have any idea about the impact on performance?
> 
> Thanks a lot
> 
> On Wed, Aug 26, 2009 at 2:59 PM, Tom Evans <te...@googlemail.com>
> wrote:
>         
>         On Wed, 2009-08-26 at 12:23 +0100, Andrew Hole wrote:
>         > Hi guys!
>         >
>         > Actually our web application has a retry mechanism based on
>         http
>         > status code returned to client. Just an example:
>         > - An http request is made to
>         http://web/software_A_folder/file.swf
>         > - if the file doesn't exist (http 404) on software_A_folder,
>         the
>         > request is made in core folder: http://web/core/file.swf
>         >
>         > This mechanism is used on entire application: when a file
>         doesn't
>         > exist on software_x_folder, a retry is made on core folder.
>         >
>         > In terms of Apache, this mechanism make always 2 requests
>         (in case of
>         > file not found).
>         >
>         > What I want to know is if there are any option on Apache to
>         handle 404
>         > status code without retry the request. When file not found,
>         some logic
>         > will handle the 404 and return the file located on other
>         folder.
>         >
>         > I appreciate your help.
>         >
>         > Best Regards,
>         > A.
>         
>         
>         This looks like a simple rewrite rule surely?
>         
>                RewriteEngine On
>                RewriteCond %{REQUEST_FILENAME} !-f
>                RewriteCond %{REQUEST_URI} ^/software_A_folder/(.*)
>                RewriteCond %{DOCUMENT_ROOT}/core/%1 -f
>                RewriteRule ^/software_A_folder/(.*) /core/$1 [L]
>         
>         Cheers
>         
>         Tom

It is two stat() calls and two regular expressions - minimal performance
impact. 

Cheers

Tom



---------------------------------------------------------------------
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] Handling 404 errors

Posted by Andrew Hole <an...@gmail.com>.
Your solutions looks very useful, but i'm afraid about impact on server
performance.

Do you have any idea about the impact on performance?

Thanks a lot

On Wed, Aug 26, 2009 at 2:59 PM, Tom Evans <te...@googlemail.com> wrote:

> On Wed, 2009-08-26 at 12:23 +0100, Andrew Hole wrote:
> > Hi guys!
> >
> > Actually our web application has a retry mechanism based on http
> > status code returned to client. Just an example:
> > - An http request is made to http://web/software_A_folder/file.swf
> > - if the file doesn't exist (http 404) on software_A_folder, the
> > request is made in core folder: http://web/core/file.swf
> >
> > This mechanism is used on entire application: when a file doesn't
> > exist on software_x_folder, a retry is made on core folder.
> >
> > In terms of Apache, this mechanism make always 2 requests (in case of
> > file not found).
> >
> > What I want to know is if there are any option on Apache to handle 404
> > status code without retry the request. When file not found, some logic
> > will handle the 404 and return the file located on other folder.
> >
> > I appreciate your help.
> >
> > Best Regards,
> > A.
>
> This looks like a simple rewrite rule surely?
>
>        RewriteEngine On
>        RewriteCond %{REQUEST_FILENAME} !-f
>        RewriteCond %{REQUEST_URI} ^/software_A_folder/(.*)
>        RewriteCond %{DOCUMENT_ROOT}/core/%1 -f
>        RewriteRule ^/software_A_folder/(.*) /core/$1 [L]
>
> Cheers
>
> Tom
>
>
>
> ---------------------------------------------------------------------
> 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] Handling 404 errors

Posted by Tom Evans <te...@googlemail.com>.
On Wed, 2009-08-26 at 12:23 +0100, Andrew Hole wrote:
> Hi guys!
> 
> Actually our web application has a retry mechanism based on http
> status code returned to client. Just an example:
> - An http request is made to http://web/software_A_folder/file.swf
> - if the file doesn't exist (http 404) on software_A_folder, the
> request is made in core folder: http://web/core/file.swf
> 
> This mechanism is used on entire application: when a file doesn't
> exist on software_x_folder, a retry is made on core folder.
> 
> In terms of Apache, this mechanism make always 2 requests (in case of
> file not found).
> 
> What I want to know is if there are any option on Apache to handle 404
> status code without retry the request. When file not found, some logic
> will handle the 404 and return the file located on other folder.
> 
> I appreciate your help.
> 
> Best Regards,
> A.

This looks like a simple rewrite rule surely?

        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_URI} ^/software_A_folder/(.*)
        RewriteCond %{DOCUMENT_ROOT}/core/%1 -f
        RewriteRule ^/software_A_folder/(.*) /core/$1 [L]
        
Cheers

Tom



---------------------------------------------------------------------
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