Handling 404 errors

Handling 404 errors

am 26.08.2009 13:23:39 von Andrew Hole

--0016364d274bcb8180047209ae2e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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.

--0016364d274bcb8180047209ae2e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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/so=
ftware_A_folder/file.swf


- if the file doesn't exist (http 404) on software_A_folder, the reques=
t is made in core folder: http://web/c=
ore/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 fold=
er.


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

What I want to know is if there are any option on Ap=
ache to handle 404 status code without retry the request. When file not fou=
nd, some logic will handle the 404 and return the file located on other fol=
der.


I appreciate your help.

Best Regards,
A.


--0016364d274bcb8180047209ae2e--

RE: Handling 404 errors

am 26.08.2009 14:21:25 von Richard Peacock

------_=_NextPart_001_01CA2647.BAF53EB5
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

From: Andrew Hole [mailto:andremailinglist@gmail.com]
Sent: 26 August 2009 12:24
To: users@httpd.apache.org
Subject: [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.







I am not sure if this would work or be what you're after as I can't test
this right now but you could point the 404 error to a PHP page which
grabs the requested URI/L and creates a re-direct to the alternative
page. Edit httpd.conf to have the line:-



ErrorDocument 404 /errordocs/404error.php



The php page would be something like:-



content=3D'1;URL=3Dhttp://www.example.com/core/$_SERVER["REQ UEST_URI"]'><=
/ht
ml>



Thinking about it, I really don't know if that would work - I've a
feeling that it would simply try to load /core/404error.php (which won't
be found, thus producing another 404 error lol!). I also think that
two, perhaps three, requests would ultimately be made (page_a -->
error.php --> page_b). Darn, sorry, this might not be much of a solution
afterall! But it might help so will submit it none-the-less.



Good luck! It would sure be interesting to know if you find a solution
and what it is!






************************************************************ **********
Privileged/Confidential Information may be contained in this
message. If you are not the addressee indicated in this
message (or responsible for delivery of the message to such
person), you must not copy, distribute or take any action in
reliance to it.
In such case, you should destroy this message and kindly
notify the sender by reply email. Please advise immediately
if you or your employer do not consent to Internet email for
messages of this kind. Opinions, conclusions and other
information in this message that do not relate to the official
business of Minorplanet Systems plc shall be understood as
neither given nor endorsed by it. Minorplanet Systems plc, Registration n=
o: 3372097
Minorplanet Limited, Registration no: 4072786
Greenwich House, 223 North Street, Leeds, LS7 2AA
VAT #: 698 1438 86
************************************************************ **********

------_=_NextPart_001_01CA2647.BAF53EB5
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" xmlns=3D"http://ww=
w.w3.org/TR/REC-html40">


>

s"
name=3D"place"/>
s"
name=3D"PersonName"/>











style=3D'font-size:10.0pt;font-family:Tahoma;font-weight:bol d'>From: n> size=3D2 face=3DTahoma> family:Tahoma'>
Andrew Hole [mailto:andremailinglist@gmail.com]

Sent: 26 August 2009 12:24=


To: =3D"on">users@httpd.apache.org

Subject: [users@httpd] Han=
dling
404 errors





=3D'font-size:
12.0pt'> 



=3D'font-size:
12.0pt'>Hi guys!



Actually our web application has a retry mechanism based on http status c=
ode
returned to client. Just an example:

- An http request is made to ..swf">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 o=
n
software_x_folder, a retry is made on core folder.



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



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



I appreciate your help.



Best Regards,

A.



windowtext 1.0pt;
padding:0cm 0cm 1.0pt 0cm'>

or=3Dnavy
face=3DArial> '> 





=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I am not sure if this would work or =
be
what you’re after as I can’t test this right now but you coul=
d
point the 404 error to a PHP page which grabs the requested URI/L and cre=
ates a
re-direct to the alternative page. Edit httpd.conf to have the line:- >



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



face=3DCourier> style=3D'font-size:10.0pt;font-family:Courier;color:green'>E rrorDocument =
404
/errordocs/404error.php



r> style=3D'font-size:12.0pt;font-family:Courier'>  font>



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>The php page would be something like=
:-



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



pan
style=3D'font-size:10.0pt;font-family:"Courier New";color:green'><html=
>< w:st=3D"on">META http-equiv=3D’refresh’ content=
=3D’1;URL=3Dhttp://www.example.com/core/$_SERVER["REQUEST_URI&qu=
ot;]’></html>



pan
style=3D'font-size:10.0pt;font-family:"Courier New";color:green'>&nb=
sp;



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thinking about it, I really don̵=
7;t
know if that would work – I’ve a feeling that it would simply=
try
to load
<=
span
style=3D'font-size:10.0pt;font-family:"Courier New";color:green'>/core/40=
4error.php
size=3D2 color=3Dnavy face=3DArial> amily:Arial;
color:navy'> (which won’t be found, thus producing another 404 erro=
r lol!). 
I also think that two, perhaps three, requests would ultimately be made (=
page_a
'font-size:
10.0pt;font-family:Wingdings;color:navy'>à
=3D2
color=3Dnavy face=3DArial> al;
color:navy'> error.php
ingdings> style=3D'font-size:10.0pt;font-family:Wingdings;color:navy'> à n> size=3D2 color=3Dnavy face=3DArial> amily:Arial;
color:navy'> page_b). Darn, sorry, this might not be much of a solution a=
fterall!
But it might help so will=
submit
it none-the-less.



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



style=3D'font-size:10.0pt;font-family:Arial;color:navy;font- weight:bold'>=
Good
luck! It would sure be interesting to know if you find a solution and wha=
t it
is!



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 







************************************************************ ****=
******
Privileged/Confidential
Information may be contained in this
message. If you are not the addr=
essee
indicated in this
message (or responsible for delivery of the message=
to
such
person), you must not copy, distribute or take any action in

reliance to it.
In such case, you should destroy this message and =
kindly

notify the sender by reply email. Please advise immediately
if yo=
u or
your employer do not consent to Internet email for
messages of this k=
ind.
Opinions, conclusions and other
information in this message that do n=
ot
relate to the official
business of Minorplanet Systems plc shall be
understood as
neither given nor endorsed by it.

Minorplanet Systems plc, Registration no: 3372097
Minorplanet Lim=
ited,
Registration no: 4072786
Greenwich House, 223 North Street, Leeds, LS7=

2AA
VAT #: 698 1438
86
************************************************************ *******=
***


 





------_=_NextPart_001_01CA2647.BAF53EB5--

Re: Handling 404 errors

am 26.08.2009 14:36:53 von Nick Kew

Richard Peacock wrote:

> *From:* Andrew Hole [mailto:andremailinglist@gmail.com]
> *Sent:* 26 August 2009 12:24
> *To:* users@httpd.apache.org
> *Subject:* [users@httpd] Handling 404 errors

Richard, when replying, can you quote normally, and not make
your reply look like some malformed signature to the original
post? I had no idea this was a reply until I hit "reply"
in my mailer.

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

ErrorDocument. That can be a script, or might even be handled
within httpd.conf with mod_rewrite.

> ErrorDocument 404 /errordocs/404error.php

Yes, that's an option.

> > content=’1;URL=http://www.example.com/core/$_SERVER["REQUEST _URI"]’>

But that is not. It's very, very evil, and damages end-users.
Your PHP (if that is your choice of scripting language) needs
to return the document you want to send.

--
Nick Kew

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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: Handling 404 errors

am 26.08.2009 15:07:48 von Richard Peacock

Nick Kew wrote:-
Richard, when replying, can you quote normally, and not make
your reply look like some malformed signature to the original
post? I had no idea this was a reply until I hit "reply"
in my mailer.


RP: Oh, I'm really sorry - I blame outlook ;) I tried to put it at the
bottom which obviously hasn't worked!! I have tried put my remarks into
your message below starting with "RP:" - sorry in advance if it causes
confusion!


> content=3D'1;URL=3Dhttp://www.example.com/core/$_SERVER["REQ UEST_URI"]'><=
/ht
ml>

But that is not. It's very, very evil, and damages end-users.


RP: Perhaps you could be kind enough to explain to me (a noob) why this
suggestion is so bad? I have used the refresh META tag myself before and
would like to know what makes it so evil!


Your PHP (if that is your choice of scripting language) needs
to return the document you want to send.


RP: Hmm, yes, this would make more sense; when the user makes a request
for page1.html, APACHE returns to the user the "404error.php" which
(when coded) will appear to contain the right document. All this would
be in a single request - although someone else who's more in the know
should be able to confirm what constitutes a request.


RP: Once again, sorry for the mis-mash mess of my original reply!


************************************************************ **********
Privileged/Confidential Information may be contained in this
message. If you are not the addressee indicated in this
message (or responsible for delivery of the message to such
person), you must not copy, distribute or take any action in
reliance to it.
In such case, you should destroy this message and kindly
notify the sender by reply email. Please advise immediately
if you or your employer do not consent to Internet email for
messages of this kind. Opinions, conclusions and other
information in this message that do not relate to the official
business of Minorplanet Systems plc shall be understood as
neither given nor endorsed by it. Minorplanet Systems plc, Registration n=
o: 3372097
Minorplanet Limited, Registration no: 4072786
Greenwich House, 223 North Street, Leeds, LS7 2AA
VAT #: 698 1438 86
************************************************************ **********


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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: Handling 404 errors

am 26.08.2009 15:59:34 von Tom Evans

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

am 26.08.2009 16:23:49 von Andrew Hole

--0016364d274b2381dc04720c33c3
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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

--0016364d274b2381dc04720c33c3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Your solutions looks very useful, but i'm afraid about impact on server=
performance.

Do you have any idea about the impact on performance?<=
br>
Thanks a lot

On Wed, Aug 26, 2009 =
at 2:59 PM, Tom Evans <te=
vans.uk
@>
=
wrote:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<=
div class=3D"h5">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 ile.swf" target=3D"_blank">http://web/software_A_folder/file.swf

> - if the file doesn't exist (http 404) on software_A_folder, the r>
> request is made in core folder: arget=3D"_blank">http://web/core/file.swf

>

> This mechanism is used on entire application: when a file doesn't<=
br>
> 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<=
br>
> 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?



=A0 =A0 =A0 =A0RewriteEngine On

=A0 =A0 =A0 =A0RewriteCond %{REQUEST_FILENAME} !-f

=A0 =A0 =A0 =A0RewriteCond %{REQUEST_URI} ^/software_A_folder/(.*)

=A0 =A0 =A0 =A0RewriteCond %{DOCUMENT_ROOT}/core/%1 -f

=A0 =A0 =A0 =A0RewriteRule ^/software_A_folder/(.*) /core/$1 [L]



Cheers



Tom







------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--0016364d274b2381dc04720c33c3--

RE: Handling 404 errors

am 26.08.2009 16:29:57 von Richard Peacock

------_=_NextPart_001_01CA2659.AF8AF0FB
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Firstly, sorry for the top post ... according to Apache.org :-



"'-F' (is existing file, via subrequest)
Checks whether or not TestString is a valid file, accessible via all the
server's currently-configured access controls for that path. This uses
an internal subrequest to do the check, so use it with care - it can
impact your server's performance!"



(http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html)



This warning is related to the "F" flag and not "f" as Tom mentioned;
surely if there was a performance issue with "f", it would be documented
as it is for "F".



I would say that performance-wise, Tom's suggestion would be the best
(compared to my random hack suggestion anyway!).

Richard.





________________________________

From: Andrew Hole [mailto:andremailinglist@gmail.com]
Sent: 26 August 2009 15:24
To: users@httpd.apache.org
Subject: Re: [users@httpd] Handling 404 errors



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






************************************************************ **********
Privileged/Confidential Information may be contained in this
message. If you are not the addressee indicated in this
message (or responsible for delivery of the message to such
person), you must not copy, distribute or take any action in
reliance to it.
In such case, you should destroy this message and kindly
notify the sender by reply email. Please advise immediately
if you or your employer do not consent to Internet email for
messages of this kind. Opinions, conclusions and other
information in this message that do not relate to the official
business of Minorplanet Systems plc shall be understood as
neither given nor endorsed by it. Minorplanet Systems plc, Registration n=
o: 3372097
Minorplanet Limited, Registration no: 4072786
Greenwich House, 223 North Street, Leeds, LS7 2AA
VAT #: 698 1438 86
************************************************************ **********

------_=_NextPart_001_01CA2659.AF8AF0FB
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" xmlns=3D"http://ww=
w.w3.org/TR/REC-html40">


i">

namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"Pers=
onName"/>









=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Firstly, sorry for the top post R=
30;
according to Apache.org :-



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>“
' nt
face=3D"Times New Roman">-F
' (is existing file, via
subrequest)

Checks whether or not TestString ont>
is a valid file, accessible via all the server's currently-configured acc=
ess
controls for that path. This uses an internal subrequest to do the check,=
so
use it with care - it can impact your server's performance! color=3Dnavy face=3DArial> al;
color:navy'>”



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>( href=3D"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.htm l">http://htt=
pd.apache.org/docs/2.0/mod/mod_rewrite.html)
p>

=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>This warning is related to the ̶=
0;F”
flag and not “f” as Tom mentioned; surely if there was a
performance issue with “f”, it would be documented as it is f=
or “F”.



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I would say that performance-wise, T=
om’s
suggestion would be the best (compared to my random hack suggestion anywa=
y!).



=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Richard.
>

=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 



=3D'font-size:
10.0pt;font-family:Arial;color:navy'> 





ize=3D3
face=3D"Times New Roman">






style=3D'font-size:10.0pt;font-family:Tahoma;font-weight:bol d'>From: n> size=3D2 face=3DTahoma> family:Tahoma'>
Andrew Hole [mailto:andremailinglist@gmail.com]

Sent: 26 August 2009 15:24=


To: =3D"on">users@httpd.apache.org

Subject: Re: [users@httpd]
Handling 404 errors
>



=3D'font-size:
12.0pt'> 



face=3D"Times New Roman">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





=3D'font-size:
12.0pt'>On Wed, Aug 26, 2009 at 2:59 PM, Tom Evans < href=3D"http://tevans.uk">tevans.uk@ >googlemail.com>
wrote:







face=3D"Times New Roman">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 href=3D"http://web/software_A_folder/file.swf" target=3D"_blank">http://w=
eb/software_A_folder/file.swf

> - if the file doesn't exist (http 404) on software_A_folder, the

> request is made in core folder: target=3D"_blank">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 o=
f

> file not found).

>

> What I want to know is if there are any option on Apache to handle 4=
04

> status code without retry the request. When file not found, some log=
ic

> will handle the 404 and return the file located on other folder.

>

> I appreciate your help.

>

> Best Regards,

> A.







=3D'font-size:
12.0pt'>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







face=3D"Times New Roman">





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project=
..

See <URL: _blank">http://httpd.apache.org/userslist.html>
for more info.

To unsubscribe, e-mail: org">users-unsubscribe@httpd.apache.org

  "   from the digest: href=3D"mailto:users-digest-unsubscribe@httpd.apache.org">us ers-digest-un=
subscribe@httpd.apache.org

For additional commands, e-mail: e.org">users-help@httpd.apache.org









=3D'font-size:
12.0pt'> 







************************************************************ ****=
******
Privileged/Confidential
Information may be contained in this
message. If you are not the addr=
essee
indicated in this
message (or responsible for delivery of the message=
to
such
person), you must not copy, distribute or take any action in

reliance to it.
In such case, you should destroy this message and =
kindly

notify the sender by reply email. Please advise immediately
if yo=
u or
your employer do not consent to Internet email for
messages of this k=
ind.
Opinions, conclusions and other
information in this message that do n=
ot
relate to the official
business of Minorplanet Systems plc shall be
understood as
neither given nor endorsed by it.

Minorplanet Systems plc, Registration no: 3372097
Minorplanet Lim=
ited,
Registration no: 4072786
Greenwich House, 223 North Street, Leeds, LS7=

2AA
VAT #: 698 1438
86
************************************************************ *******=
***


 





------_=_NextPart_001_01CA2659.AF8AF0FB--

Re: Handling 404 errors

am 26.08.2009 16:44:00 von Tom Evans

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