Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Site Upgrade With Mod_Rewrite



Have you ever had the job of upgrading a site and wanted to check that everything is fine before you set the server live? This short article will show you an example of how you can check the site live while the rest of the world will get a page which tells them that the site is being maintained.

Using mod_rewrite you can do a lot of manipulation with URL's. The example below will serve the page upgrading.php if they do not come from the IP address 10.10.10.10. The rewrite rule part: !\.(gif)$ tells the server to serve .gif files even if they do not come from the correct IP address, so that you can have images on your update page.


RewriteCond %{REMOTE_ADDR} !^10.10.10.10$
RewriteRule !\.(gif)$ /var/www/upgrading.php



If you're already using rewrite rules for your site you can do like the example below ( use [S=2] ). [S=2] means "skip the next two rewrite rules", this the the rewrite way of constructing if then else statements. The example below shows how you can use this technique with eZ publish to show an alternative page for users not comming from the IP address 10.10.10.10. This is very useful when you are upgrading your site. Just remember to remove the rewrite condition when you are done.


RewriteCond %{REMOTE_ADDR} !^10.10.10.10$
RewriteRule !\.(gif)$ /var/www/upgrading.php [S=2]

RewriteRule ^/filemanager/filedownload/([^/]+)/(.*)$  /var/www/ezfilemanager/files/ [T="application/oct-stream",S=1]
RewriteRule !\.(gif|css|jpg|png)$ /var/www/index.php


A few useful links:
Module mod_rewrite URL Rewriting Engine
Apache 1.3 URL Rewriting Guide


| Printer-friendly page |

Comment List


Topic: Author:
Time:
BAD links! Andrzej Reszel 01.08.2002 16:34

http://www.apache.org/DELETE_ME/mod/mod_rewrite.html

and

http://www.apache.org/DELETE_ME/misc/rewriteguide.html

should use /docs intead of /DELETE_ME




Forgot your password?

Register a new user

Results

Polls