views:

45

answers:

2

I have an online store that i have recently re-written most of and would like to upload it to my server. While the maintenance is taking place, i would like to redirect all visitors to an "under construction" page. (easily done with php or apache htacess etc...)

The issue is that I would like to test everything when i upload it so i still need access while blocking everyone else. I was thinking some php page that is open to all with a cookie flag i could set for just myself?

What is the best way to do this? Thanks jme

+1  A: 

This should handle what your trying to do:

http://www.theblog.ca/redirect-by-ip-htaccess

beckelmw
I would also do this by changing the webserver configuration. Ie. only allow local access for testing and redirect all remote access to a "temporary down for maintenance" page. You can do this combining mod_rewrite and adding rewrite rules that test on %{REMOTE_ADDR}.
wimvds
A: 

.htaccess:

# prevent infinite redirect loops
RewriteCond %{REQUEST_URI} !^/back-soon-updating.php$
# not on development server (i.e. .com instead of .dev)
RewriteCond %{HTTP_HOST} .com$
# let admins enter to verify the update has worked
RewriteCond %{QUERY_STRING} !c=u
RewriteRule .* back-soon-updating.php [L,R=302]

Change the "!c=u" line to whatever you want, e.g. allow an IP address.

Coronatus