You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Evaldas Imbrasas <ev...@imbrasas.com> on 2006/08/22 06:02:49 UTC

[users@httpd] 503 response with mod_rewrite?

Hi all,

Is there a way to return a custom document along with a 503 Network
Unavailable response code using mod_rewrite rules? The documentation
mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
are unavailable - is there a specific reason why?

In case you're wondering why I would like to return a 503 code -
Google recommends returning it for 'down for maintenance' pages:
http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.html

Thanks,
  Evaldas

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by André Malo <nd...@perlig.de>.
* Evaldas Imbrasas wrote: 

> Is there a way to return a custom document along with a 503 Network
> Unavailable response code using mod_rewrite rules? The documentation
> mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
> are unavailable - is there a specific reason why?
>
> In case you're wondering why I would like to return a 503 code -
> Google recommends returning it for 'down for maintenance' pages:
> http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.ht

It should be possible as of httpd version 2.2 (bad documented, right)

nd

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by alan bryan <al...@gmail.com>.
Here's what we use.  We have this at the bottom of our <VirtualHost>
sections and just uncomment and restart apache before working on the
sites.

#Uncomment to redirect temporarily while working on site
#ErrorDocument 503 /503.php
#RedirectMatch 503 ^/(?!(503\.php|503\.gif))

Not sure if that's the "right" way to do it but it works for us.

--Alan



On 8/21/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> Hi all,
>
> Is there a way to return a custom document along with a 503 Network
> Unavailable response code using mod_rewrite rules? The documentation
> mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
> are unavailable - is there a specific reason why?
>
> In case you're wondering why I would like to return a 503 code -
> Google recommends returning it for 'down for maintenance' pages:
> http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.html
>
> Thanks,
>   Evaldas
>
> ---------------------------------------------------------------------
> 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
>
>

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Joshua Slive <jo...@slive.ca>.
On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> > It would be no more performance-draining to check for an .htaccess
> > file than it would be to check for any other file as a condition for
> > issuing a 503.
>
> If .htaccess files are enabled, Apache would check for their existance
> recursively, wouldn't it? Meaning, for a requested file that is 4
> directories deep it would do 5 .htaccess existence checks.

Only if you ask for it.  You can turn AllowOverride on or off for any
directory.  You would simply need it on for one directory.  (I'm not
saying it's a good idea.  I'd recommend simply changing httpd.conf and
gracefully restarting.  But if you want to trigger off the existence
of a file, you might as well use .htaccess.)

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] 503 response with mod_rewrite?

Posted by Evaldas Imbrasas <ev...@imbrasas.com>.
> It would be no more performance-draining to check for an .htaccess
> file than it would be to check for any other file as a condition for
> issuing a 503.

If .htaccess files are enabled, Apache would check for their existance
recursively, wouldn't it? Meaning, for a requested file that is 4
directories deep it would do 5 .htaccess existence checks.

-- 
-----------------------------------------------------
Evaldas Imbrasas
http://www.imbrasas.com

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Joshua Slive <jo...@slive.ca>.
On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> On 8/25/06, Joshua Slive <jo...@slive.ca> wrote:
> > On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> > > Is there a way to do this redirect on a conditional as a rewrite rule
> > > allows, though? I.e., return a 503 if a certain file exists?
> >
> > Sure, just make "a certain file" an .htaccess file in the DocumentRoot
> > containing that directive.  Otherwise, if Andre is right, you can use
> > all the tricks of mod_rewrite directly.
>
> Unfortunatelly, that is not an option, as my site is optimized for
> speed and therefore is not using .htaccess files. Upgrading to 2.2 is
> not possible in short-term either.

It would be no more performance-draining to check for an .htaccess
file than it would be to check for any other file as a condition for
issuing a 503.

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] 301 redirect with mod_rewrite? Possible to use relitive paths rather then FQDN paths?

Posted by Joshua Slive <jo...@slive.ca>.
On 8/25/06, John H. Nyhuis <ca...@u.washington.edu> wrote:
>         I was wondering if anyone has given thought to allowing the use of
> relative paths with the mod_rewrite package rather then requiring full
> paths.  i.e., in the .htaccess file:
>
> "Redirect 301 ./neuro.asp ../neurology.php" (does not work)
>
> instead of:
>
> "Redirect 301 /pedtest/divisions/neuro/neuro.asp
> http://depts.washington.edu/pedtest/divisions/neurology.php"
>
> (does work)
>
> Just asking because our dev->testing->production setup has different
> absolute FQDN's at each spot, and this means the .htaccess file is
> specific to each of the environments.  It would be convenient to not have
> to remember to change the .htaccess file each time a new site version gets
> pushed through the process.

You can't use relative paths, but you can accomplish the same thing:
RewriteRule (.*)(/[^/]*)/neuro.asp $1/neurology.php [R=301]

(That may need to be adjusted, but it should give you the idea.)

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


[users@httpd] 301 redirect with mod_rewrite? Possible to use relitive paths rather then FQDN paths?

Posted by "John H. Nyhuis" <ca...@u.washington.edu>.
 	I was wondering if anyone has given thought to allowing the use of 
relative paths with the mod_rewrite package rather then requiring full 
paths.  i.e., in the .htaccess file:

"Redirect 301 ./neuro.asp ../neurology.php" (does not work)

instead of:

"Redirect 301 /pedtest/divisions/neuro/neuro.asp 
http://depts.washington.edu/pedtest/divisions/neurology.php"

(does work)

Just asking because our dev->testing->production setup has different 
absolute FQDN's at each spot, and this means the .htaccess file is 
specific to each of the environments.  It would be convenient to not have 
to remember to change the .htaccess file each time a new site version gets 
pushed through the process.

 	Thanks,

John H. Nyhuis
Sr. Computer Specialist
Dept. of Pediatrics
HS RR338, Box 356320
University of Washington
Desk: (206)-685-3884
cabal@u.washington.edu


---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Bob Ionescu <bo...@googlemail.com>.
Evaldas Imbrasas wrote:
> On 8/25/06, Joshua Slive <jo...@slive.ca> wrote:
>> On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
>> > Is there a way to do this redirect on a conditional as a rewrite rule
>> > allows, though? I.e., return a 503 if a certain file exists?
>>
>> Sure, just make "a certain file" an .htaccess file in the DocumentRoot
>> containing that directive.  Otherwise, if Andre is right, you can use
>> all the tricks of mod_rewrite directly.
> 
> Unfortunatelly, that is not an option, as my site is optimized for
> speed and therefore is not using .htaccess files.

Well, use a directory section in your httpd.conf as recommended and 
described in http://httpd.apache.org/docs/trunk/howto/htaccess.html#when 
(When (not) to use .htaccess files).

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Evaldas Imbrasas <ev...@imbrasas.com>.
On 8/25/06, Joshua Slive <jo...@slive.ca> wrote:
> On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> > Is there a way to do this redirect on a conditional as a rewrite rule
> > allows, though? I.e., return a 503 if a certain file exists?
>
> Sure, just make "a certain file" an .htaccess file in the DocumentRoot
> containing that directive.  Otherwise, if Andre is right, you can use
> all the tricks of mod_rewrite directly.

Unfortunatelly, that is not an option, as my site is optimized for
speed and therefore is not using .htaccess files. Upgrading to 2.2 is
not possible in short-term either.

But thanks for your suggestions guys.

-- 
-----------------------------------------------------
Evaldas Imbrasas
http://www.imbrasas.com

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Joshua Slive <jo...@slive.ca>.
On 8/25/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> Is there a way to do this redirect on a conditional as a rewrite rule
> allows, though? I.e., return a 503 if a certain file exists?
>
>
> > > Is there a way to return a custom document along with a 503 Network
> > > Unavailable response code using mod_rewrite rules? The documentation
> > > mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
> > > are unavailable - is there a specific reason why?
> >
> > I don't think mod_rewrite can do it.  (I haven't tried it, but the
> > code seems to enforce 3xx on the R flag.)  But it is easier with
> > mod_alias anyway:
> >
> > Redirect 503 /

Sure, just make "a certain file" an .htaccess file in the DocumentRoot
containing that directive.  Otherwise, if Andre is right, you can use
all the tricks of mod_rewrite directly.

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] 503 response with mod_rewrite?

Posted by Evaldas Imbrasas <ev...@imbrasas.com>.
Is there a way to do this redirect on a conditional as a rewrite rule
allows, though? I.e., return a 503 if a certain file exists?


> > Is there a way to return a custom document along with a 503 Network
> > Unavailable response code using mod_rewrite rules? The documentation
> > mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
> > are unavailable - is there a specific reason why?
>
> I don't think mod_rewrite can do it.  (I haven't tried it, but the
> code seems to enforce 3xx on the R flag.)  But it is easier with
> mod_alias anyway:
>
> Redirect 503 /
>

-- 
-----------------------------------------------------
Evaldas Imbrasas
http://www.imbrasas.com

---------------------------------------------------------------------
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] 503 response with mod_rewrite?

Posted by Joshua Slive <jo...@slive.ca>.
On 8/22/06, Evaldas Imbrasas <ev...@imbrasas.com> wrote:
> Hi all,
>
> Is there a way to return a custom document along with a 503 Network
> Unavailable response code using mod_rewrite rules? The documentation
> mentions the ability to return 3xx and 4xx, but not 5xx. If 5xx codes
> are unavailable - is there a specific reason why?
>
> In case you're wondering why I would like to return a 503 code -
> Google recommends returning it for 'down for maintenance' pages:
> http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.html

I don't think mod_rewrite can do it.  (I haven't tried it, but the
code seems to enforce 3xx on the R flag.)  But it is easier with
mod_alias anyway:

Redirect 503 /

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