Forum Moderators: phranque

Message Too Old, No Replies

Redirecting website to maintenance page during server down.

Without using .htaccess, i want to redirect to maintanance page

         

satheeshkumar

5:27 pm on Jun 15, 2011 (gmt 0)

10+ Year Member



Hi,

I want to redirect the users of my server to a maintenance page during my server maintanance. I dont want to use .htaccess and will directly insert the code inside that particular virtualhost.

I tried adding

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !/test.html$
RewriteCond %{REMOTE_HOST} !^10\.125\.***\.**

RewriteRule $ /test.html [R=302,L]

and all my request are redirecting to test.html page.

But i am not able to access it from my PC ip 10.125.***.**.

Can anyone help on this..

[edited by: tedster at 3:09 am (utc) on Jun 16, 2011]
[edit reason] obsure the exact IP address [/edit]

g1smd

7:01 pm on Jun 15, 2011 (gmt 0)

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



You need to test REMOTE_ADDR not REMOTE_HOST.

However, you should not redirect the requests.

You should serve "503 Service Unavailable" instead.

satheeshkumar

10:02 am on Jun 16, 2011 (gmt 0)

10+ Year Member



Hi,

Many thanks for the suggestion as it really worked.

But may i know the use of 503 redirect as the end users need to see a maintenance message and 302 redirecting to test.html and we will post a maintenance message in that page.

If we need 503 redirect, will it be like
RewriteRule $ /test.html [R=503,L]

I am not clear what the L in [R=503,L] really means..

lucy24

5:52 pm on Jun 16, 2011 (gmt 0)

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



[L] means "stop here and don't continue to the bottom of the page looking for any other rewrite rules that may apply".

You can write a custom page for any error message. Depending on your host, some may have default names that it looks for. If not, put a line in your .htaccess or equivalent saying what to use for the page. You can point various kinds of errors to the same physical page (404 and 410 is an obvious one), so long as you're giving the user the right information.

There are two pieces of information and they're not necessarily related. One is what you tell your server, the search engines and so on. That's the magic number 503. The other is what you tell humans. That's your custom page, which can have any name you like, so long as the computer can find it.

The server can find a custom 50x page even if a mistake in your htaccess results in nobody getting through to the site. Guess how I know this.

g1smd

7:01 pm on Jun 16, 2011 (gmt 0)

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



Get over this word "redirect". It has a very specific meaning and doesn't apply to what you should do.

But may i know the use of 503 redirect as the end users need to see a maintenance message

A redirect returns a 30x HTTP status code. You need "503 Service Unavailable".

and 302 redirecting to test.html and we will post a maintenance message in that page.

You absolutely do NOT need a 302 redirect.