Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member
    Join Date
    Mar 2011
    Location
    Nashville, TN
    Posts
    340
    Member #
    27244
    Liked
    26 times
    I have had major problems with my hosting company and their SQL server going down. It has gone down 8 times in two months. That being said I have several wordpress sites that go down. I was wanting to modify my .htaccess page to go to an .html file that will display down for maintenance instead of a horrible blank screen when people view the site. What is the best way to write this for that?


  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    I don't think that is the purpose of a .htaccess redirect, and don't believe what you want it to do can be done.

    I know wih ASP on a windows server, I have a function that checks to see if the DB connection is live or not, I prefer to call an "include" which basically informs if the DB is down, instead of a redirect, but I assume a redirect is possible, just never needed to do it that way.

    I'm sure that can be done in PHP as well, I'm just not that familiar with it.

    I may be wrong about the .htaccess part, but never heard of it being used like that.

    On a slightly different note, if the DB server is really going down that often, are they "the hosting company" , making any efforts to fix it ? If not, I believe I'd find a different host.

  4. #3
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    Quote Originally Posted by Webzarus, post: 242056
    I don't think that is the purpose of a .htaccess redirect, and don't believe what you want it to do can be done.

    I know wih ASP on a windows server, I have a function that checks to see if the DB connection is live or not, I prefer to call an "include" which basically informs if the DB is down, instead of a redirect, but I assume a redirect is possible, just never needed to do it that way.

    I'm sure that can be done in PHP as well, I'm just not that familiar with it.

    I may be wrong about the .htaccess part, but never heard of it being used like that.

    On a slightly different note, if the DB server is really going down that often, are they "the hosting company" , making any efforts to fix it ? If not, I believe I'd find a different host.
    Maybe you could use a php require.
    How I think this could work is you include something that connects to the database first, before the rest of the pages loads. If this fails, the page would hang at a sort of Temporary Maintenance page. If it's successful, it loads the rest of the page on top of it.

  5. #4
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    His page is already doing that, what I was talking about was an if then else statement, where you make a DB call, if nothing is returned the include page is loaded and the script stops running, if the DB returns the value you're looking for, it sets a session variable, so that check doesn't have to run every time a page is called. Once the user closes the browser, the session variable is dropped. If and when they return, the same check happens again.

    The point of host post was to display SOMETHING to the user, even if the DB server is unavailable.

  6. #5
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    Quote Originally Posted by Webzarus, post: 242070
    His page is already doing that, what I was talking about was an if then else statement, where you make a DB call, if nothing is returned the include page is loaded and the script stops running, if the DB returns the value you're looking for, it sets a session variable, so that check doesn't have to run every time a page is called. Once the user closes the browser, the session variable is dropped. If and when they return, the same check happens again.

    The point of host post was to display SOMETHING to the user, even if the DB server is unavailable.
    I guess we were saying almost the same thing; yours just actually makes sense, whereas mine doesn't.

    @original poster: Webzarus's solution makes sense. Try it!

  7. #6
    Senior Member
    Join Date
    Mar 2011
    Location
    Nashville, TN
    Posts
    340
    Member #
    27244
    Liked
    26 times
    ya Ive been moved to three different servers and so far Ive had another year added to my hosting for all the issues. I might use them for just simple sites and bounce to someone else for db hosting. I still would like to figure out how to get this to work. I have many wordpress hosted sites and small forums I have done that I can not allow a black page or SQL error to be displayed.


  8. #7
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times

  9. #8
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    I know cPanel has a remote MySQL option. You could pick up a cheap web hosting plan from another provider, then use that to hold the database while still hosting your site on the other host. Only problem here is that the database might take longer to load if the hosting is geographically far away, or there is high latency between the two hosts.
    Hope that helps,
    shovenose

  10. #9
    Senior Member
    Join Date
    Mar 2011
    Location
    Nashville, TN
    Posts
    340
    Member #
    27244
    Liked
    26 times
    so in theory how does a 404 error page play into this?? I was under the impression that it was obtained in the .htaccess page.


  11. #10
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Me personally, I'd not use a 404 page as that tells search engines that the site or page is not available.

    I'd create a generic page using HTML and statically mapped graphics, and just put a simple message like "the site is currently down for maintenance" please check back later, apologize for the inconvience.

    But that's just how I would do it. I would also embed an email script in it to send me a message letting me know when users are getting this message.

    Personally though, seriously, I'd find another hosting provider if this occurs too often. There's normally just a short list of reasons why a DB server is unavailable, and they all have to so with the hosting providers lack of control or optimization a on their DB SERVERS.

    You shouldn't have to code around your hosting providers issues... Period.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:48 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com