Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quick way to create a maintenance page?


zefeena

Recommended Posts

Hi,

 

I need a quick way, and as little coding as possible, to put a website into 'maintenance mode', i.e so it just goes to a holding page and no-one can purchase/view or otherwise engage with eh website.

 

Options please, thank you

 

Running a botched up version of  osCommerce Online Merchant v2.3.4 bootstrap with the dresscode theme installed, numerous add-ons, terrible coding, terrible website, but will have to make do until I have made up for my losses and can risk shutting down for a couple of weeks while I start all over again. - I did not install my program but am endeavouring to fix it with your help.

Link to comment
Share on other sites

20 minutes ago, zefeena said:

so it just goes to a holding page and no-one can purchase/view or otherwise engage with eh website.

If don't wish to let them see or do anything then a simple html index page is all you need. You can edit it and add an email is you like. Just dd it to the root of your site or which ever directory you redirect to when someone lands on your site. When your ready just remove that one file and your done.

image.thumb.png.5026d7aabf0438f2ed567165b915a4b0.png

index.html.html

 

Link to comment
Share on other sites

Zahid's method works only if the server processes the html BEFORE php, which is not the case on my server. That would not work on my site.

But I'm not sure it works when a product page is called directly.

 

with OsC 2.2 since 2006 ...

Link to comment
Share on other sites

9 minutes ago, bonbec said:

Zahid's method works only if the server processes the html BEFORE php, which is not the case on my server. That would not work on my site.

Also would not work if you go to a non index.php based page.

Phoenix support now at https://phoenixcart.org/forum/
App created for phoenix
TinyMCE editor for admin

 

Link to comment
Share on other sites

Ok, so I wouldn't go for the index.html route.  This will only work if visitors arrive directly to your domain name i.e. not a category, not a product page etc.  Most visitors to your site will be arriving from Google or similar so the chances of them being taken to your homepage are slim as the search engine will take them to the most relevant page based on their search.

This is my quick and dirty fix.  It works based on IP address and allows you to enter your IP so that you can continue to view the site whilst it's in maintenance. 

Everything I do has keeping the Search Engines happy as a priority, never put your site into maintenance without setting 503 status code.  This will tell the Search Engines that the page/site is temporarily under maintenance and to NOT reindex your site overwriting the previous correct page content with the temporary maintenance content (otherwise you'll end up with 1000's of entries in Google saying "We're under maintenance".  There's also a setting to inform the search engines when to revisit i.e. when you will be finished performing maintenance.  This is only a suggestion and the search engines don't have to honour your suggestion.

There is one caveat, if your site is behind a service such as Cloudflare then the $_SERVER['REMOTE_ADDR'] will not be able to get your IP address so you wont be able to see the front-end of the store either.

Paste this in the very top of your includes/application_top.php file just after the <?php tag

<?php
$showMaintenancePage = false;
$showStoreToVIP = 'ENTER YOUR IP HERE'; // Enter your IP here
$tellSearchEnginesToRevistAfter = '3600'; //This tells the search engines the amount of seconds to wait (or you can enter a date in this format: Wed, 21 Oct 2015 07:28:00 GMT) before revisiting if they crawl your pages during maintenance

function set_503_header() {
  global $tellSearchEnginesToRevistAfter;
    $protocol = 'HTTP/1.0';

    if ( $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1' ) {
        $protocol = 'HTTP/1.1';
    }

    header( $protocol . ' 503 Service Unavailable', true, 503 );
    header( 'Retry-After: 3600' );
}
if($_SERVER['REMOTE_ADDR'] != $showStoreToVIP && $showMaintenancePage){
  set_503_header();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Your Company/Site Name</title>
<style type="text/css">
body,td,th { color: #81B600; font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px;}
body { background-color: #FFFFFF; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}
h1 { font-size: 30px; color: #81B600;}
h2 { font-size: 18px; color: #81B600;}
div{ margin-top:50px; text-align:center;}
</style>
</head>

<body>
<div>
<h1>Your Site Name</h1>
<h2>Tel: 01234 123456</h2>
<p>We are currently performing maintenance on our site.</p>
<p>Please accept our apologies for any inconvenience caused and check back soon.</p>
</div>
</body>
</html>
<?php
	exit();
}

 

It's just a basic HTML page, Change the style/contents to suit your needs.

To activate the code change $showMaintenancePage to true, $showStoreToVIP to your IP address and enter the amount of seconds you think you'll be likely performing maintenance or a date when you'll be finished.

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

Ok my bad! I was under the assumtion op wanted a quick simple solution involving very little code. So something a bit more robust but still simple?

Well just add 503.php file to your root directory and edit the html in it as you like.

The to stop osC beeing got at by google or anything else, edit your .htaccess file to redirect all visitors to your 503.php page by adding the following lines.

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111
RewriteCond %{REQUEST_URI} !/503.php$ [NC]
RewriteRule .* /503.php [R=302,L]

Repalce  111\.111\.111\.111 with your own ip address. Simple no need to edit any osC files.

Better still you should never take a shop of line, It's so simple to set up a second shop in a sub directory then you can do any changes on that while still keeping the main shop live. Then when you are ready just copy them over to the live site. . Your customers will never know :)

Sample is running on my custom test site feel free to try , Image and count down optional ?

https://jcmagpie.com

image.png.5cfd6641125cf776952f6d75b80a856e.png

503.php

 

Link to comment
Share on other sites

42 minutes ago, JcMagpie said:

RewriteRule .* /503.php [R=302,L]

I like your solution but shouldn't that be [R=503,L] and then not have it in the 503.php page?

Setting 302 before 503 could cause some issues and the search engines may only accept the first.

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

Good question, I've personaly have never had any issues but then I'm no apache redirect expert. Was given the redirect when doing some work on a sever a few years ago by the server tech section of the host. Worked fine did not see any issues. As far as I know a 503 redirecting to maintenance page during a short maintenance slot is fine with Google.

Feel free to change and use as needed. If you feel it's beter the other way round go for it. My experiance with apache redirects, allways more than one way to achive the same result. I have only ever used it for a few days at most. If your planing a long hiatus then you will need an alternative solution.

I would recomend best follow the advice of a developer or your host.

 

Link to comment
Share on other sites

@zefeena

The add-on that @bonbec linked to in the 2nd post in this tread allows you to go into and out of maintenance mode through Admin. It will backup .htacces file and create a new one automatically when you go into maintenance mode. When reverting back to online mode, it restores your original .htaccess file. I do not see many (if any) core file changes in it.

(I do not use this add-on. I actually use a much older add-on, which did modify core files. Apparently, the one listed above was inspired by the older one I am using.)

Also, @burt created a Maintenance Mode module in one of his earlier 28-day bundles (2016-#18).

HTH

M

Link to comment
Share on other sites

@JcMagpie on second thoughts you're right, 302 is correct, at first glance I thought it was just doing a rewrite of the URL but it's redirecting so 503.php would be seen in the address bar so a 302 temporary redirect status code is absolutely correct.

It's been a long day, ignore me! lol

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

I'm not sure how long I'm putting the site off-line - the reasons are complicated! 

I'll take a look at the add-on.  I have used the old one before before many years ago, so that my be the easiest for me as its accessible via admin.   Thanks guys.  Have a nice evening.

Running a botched up version of  osCommerce Online Merchant v2.3.4 bootstrap with the dresscode theme installed, numerous add-ons, terrible coding, terrible website, but will have to make do until I have made up for my losses and can risk shutting down for a couple of weeks while I start all over again. - I did not install my program but am endeavouring to fix it with your help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...