Forum Moderators: phranque

Message Too Old, No Replies

Apache httpd.conf RewriteRule shows 500 error on first hit

Apache httpd.conf RewriteRule shows 500 error on first hit

         

chandrashekhard

9:05 am on Jun 7, 2012 (gmt 0)

10+ Year Member




Hi All,

I want to set the maintanance page for our site when Application server goes down
I set Rule

RewriteRule ^/$ /maintenance.html [L,NE]

in httpd.conf on our web server in <VirtualHost *:80>
so that every request should redirect to maintenance.html

But the problem is for the first time when user hit the browser is show 503 error page and on refresh or next it
it goes to the maintenance.html.

our app run on https and we have the ssl.conf include in httpd.conf
Any body know why this show 503 on first hit ?

below is my rewite log



ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (2) init rewrite engine with requested uri /
ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (3) applying pattern '^/$' to uri '/'
ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (2) rewrite '/' -> '/maintenance.html'
ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (2) local path result: /maintenance.html
ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (2) prefixed with document_root to /var/www/htm
l/maintenance.html
ip - - [07/Jun/2012:00:32:40 --0700] [myhostname/sid#2b32fe4
a7db8][rid#2b330a4666e0/initial] (1) go-ahead with /var/www/html/maintenance.htm
l [OK]


So ....
ISSUEE >> local path result: /maintenance.html 500

WORK FINE >> /var/www/html/maintenance.html [OK]

chandrashekhard

1:43 pm on Jun 7, 2012 (gmt 0)

10+ Year Member



Along with this Issue .. our https Rewrite rule work inconsistently. its works from some machine but some machine gives 500 error

lucy24

6:13 pm on Jun 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I set Rule

RewriteRule ^/$ /maintenance.html [L,NE]

in httpd.conf on our web server in <VirtualHost *:80>
so that every request should redirect to maintenance.html

The Rule, as written, does not do what you say. It takes only requests for the top-level Index file-- with or without query-- and rewrites (not redirects) to www.example.com/maintenance.html

What is the [NE] intended to do? As an internal rewrite without query string, it would seem to be totally superfluous.

Why don't you just use ErrorDocument to set a custom 500 page?

And now read the Sticky about using example.com

g1smd

8:00 pm on Jun 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If your maintenance page does not itself send a 503 HEADER as the very first action then your site is misconfigured.

As written now, you serve your maintenance page with "200 OK" status. This is a disaster.

You need to rewrite all requests for all URLs to instead serve your maintenance page. Do this such that the page is returned at the originally requested URL.

RewriteCond %{REQUEST_URI} !maintenance 
RewriteRule .* /maintenance.php [L]


In the PHP file send 503 status using the HEADER directive. The page must return 503 status: not 404, not a redirect, and not 200. Follow it with the usual human-readable message.