WebFaction
Community site: login faq

hi,

I want to shut down my site (in django on Apache) for a day to upload many changes (and do some more testing). What I would like to do is to redirect all incoming traffic to a static page (that says that we will be back shortly), but the requests from my (and my collegues) IP address should work normally.

Is that possible? How?

asked 16 Oct '12, 07:11

xpanta
622844
accept rate: 0%


Another option you might want to take a look at is django-maintenancemode. That will allow you to put up a static page to let your visitors know the site is down for maintenance but still allow you to work on the site.

There is this one as well django-site-maintenance

permanent link

answered 16 Oct '12, 10:20

bmeyer71 ♦♦
1.5k3613
accept rate: 33%

edited 16 Oct '12, 10:45

Thank you. django-site-maintenance plugin seems more active and both are very easy to install and configure.

(17 Oct '12, 06:41) xpanta

Hi,

You can accomplish this using mod_rewrite via .htaccess. Here are some sample rules you can add:

RewriteEngine on
RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx
RewriteCond %{REQUEST_URI} !/staticpage\.html$
RewriteRule (.*) /staticpage.html [R=302,L]

This would redirect all users that don't have the IP xxx.xxx.xxx.xxx to the "/staticpage.html" URL.

I hope this helps.

permanent link

answered 16 Oct '12, 07:40

todork
1.2k5
accept rate: 34%

Thank you. Is it possible to not redirect for two or more IPs? Do I also need to configure Nginx?

(17 Oct '12, 06:40) xpanta

I have a questions about the Apache redirect script. If I want to redirect my site to a maintenance page. Would I change the rules to the following example below?

RewriteEngine on
RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx
RewriteCond %{REQUEST_URI} !/example\.com$
RewriteRule (.*) /maintenance.html [R=302,L]
permanent link

answered 25 Nov '14, 18:35

jcorbind
1314
accept rate: 0%

edited 25 Nov '14, 20:19

seanf
12.2k41836

No, it won't. You're using a host name in the REQUEST_URI test, which won't work.

If you want to redirect requests for example.com, except those requests that come from xxx.xxx.xxx.xxx, then the rules would be something like:

RewriteEngine on
RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx
RewriteCond %{SERVER_NAME} ^example\.com$
RewriteRule (.*) /maintenance.html [R=302,L]
(25 Nov '14, 20:25) seanf

Thank you sir for clarifying that. I came from Cpanel which I used for handling redirects. Obviously it makes it much easier, but not as flexible.

Edit: I also found a simple script pretty much similar to the ones mentioned. Tested and works! :-)

(26 Nov '14, 01:21) jcorbind
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225

question asked: 16 Oct '12, 07:11

question was seen: 4,492 times

last updated: 26 Nov '14, 01:27

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM