Page 1 of 1

Closing Store for Maintenance

Posted: Tue Jul 07, 2009 7:07 pm
by manamana
This was discussed over at interspire. I think most people put a closed message on the home page and turn off purchasing. I wasn't happy with that method so this is what I came up with. This will show the page, maintenance.html (customized as you see fit), to all visitors when you enable it in your .htaccess file. You can specify it to allow your IP so you will still be able to access the site to do maintenance. Just don't forget that you've got it in maintenance mode because the site will look normal to you and inaccessible to everyone else. ;)

1. Create a file called maintenance.html and put it in the store root directory. Customize it with your closed for maintenance message.
2. Add the following code to the .htaccess in the store root directory:

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect everyone who's not from your IP
RewriteCond %{REMOTE_ADDR} !123.456.789.10 [NC]
# Allow real files to be served
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !maintenance.html$ /maintenance.html [R=307,L]
</IfModule>
3. Replace 123.456.789.10 with your IP. (You can use http://www.whatismyip.com to find out what it is.)
4. When you are not in maintenance mode, comment out all the lines. Uncomment the lines when you want to go into maintenance mode.

Credits: http://www.randomsequence.com/articles/ ... t-your-ip/

Re: Closing Store for Maintenance

Posted: Sun Aug 09, 2009 5:31 pm
by CharlieFoxtrot
This works perfectly! ~ Thank you!



edit: After a bit of googling, I now understand that the "307" tells the search engines that it's a temporary redirect.

Re: Closing Store for Maintenance

Posted: Sun Aug 09, 2009 9:29 pm
by CharlieFoxtrot
I just found another handy use for this... as a redirect AWAY from my development directory.

On a very *rare* occasion, a random customer will wander in to my ISC development directory and browse the version of my store that I'm working on. Harmless enough, I guess... but it is an annoyance for them to discover that they can't check out, or to discover that I'm not actually selling the demo items that come pre-stocked with the ISC installation.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect everyone who's not from your IP
RewriteCond %{REMOTE_ADDR} !123.456.789.10 [NC]
# Allow real files to be served
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !maintenance.html$ /my-live-store-dir/index.php [R=307,L]
</IfModule>
The only thing I changed appears in red:
RewriteRule !maintenance.html$ /my-live-store-dir/index.php [R=307,L]

This redirects any visitors who don't have my IP address to the actual store location. I didn't change the "!maintenance.html$" because I'm sending the visitor OUT of the development directory anyway.

~ Charlie

PS: Any idea HOW someone might be stumbling into my development directory? Are the search engines finding it? Is ISC announcing itself to search engines?

Re: Closing Store for Maintenance

Posted: Mon Aug 10, 2009 1:57 pm
by Martin
CharlieFoxtrot wrote:PS: Any idea HOW someone might be stumbling into my development directory? Are the search engines finding it? Is ISC announcing itself to search engines?
If you're using something like a googletoolbar, desktop or similar then it's possible that they are tattling on you...

Re: Closing Store for Maintenance

Posted: Mon Aug 10, 2009 5:45 pm
by Tony Barnes
Nice trick