SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Posts rarely lloydi's Avatar
    Join Date
    Jan 2002
    Location
    Swindon UK
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Site unavailable - can I use some kind of 'switch'

    I've been pondering an idea - if I am updating a MySQL db, I'd like to temporarily switch off the site. I was thinking of placing a command in a common include file - the first file that is included in all pages. If I have set the db so that the site is unavailable, I'd like to redirect to a generic 'site being updated' page. This is what I tried:

    if ($row_rsSiteAvailability['site_availability']==0)
    {
    header("Location: /site-unavailable/");
    }

    But in Firefox it's moaning about the redirect.

    "Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked."

    Can someone suggest what I'm doing wrong? Or a better way of doing this?

    On a similar topic, rather than doing a redirect, is there a PHP command that basically means "stop processing enything else on this page". If that's possible, I could write out the 'site being updated' message and then do that stop command.

    Any tips appreciated!
    Build Your Own Web Site the Right Way!
    A beginners' HTML/CSS book with web standards at its heart
    The Ultimate HTML Reference
    A complete reference, in glorious hardback

  2. #2
    SitePoint Member phrozen_ra's Avatar
    Join Date
    Nov 2004
    Location
    Iasi
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actualy there is a command that says stop everything )

    it is return 0;

    You can put that wherever you want it on your page (but take care to put it after you send the message 'page is being updated' ... or whatever you want to output)

    Good luck...
    Tutorials 4 You - A huge database of Free Tutorials
    phrozenfire Tutorials

  3. #3
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A better command to stop processing everything following that command is
    PHP Code:
    <?php
    exit("Some Message Here, its optional");
    $ab 1;
    // some code here
    ?>
    or
    PHP Code:
    <?php
    die("Some Message Here, its optional");
    $ab 1;
    // some code here
    ?>
    both of the above codes will output the message
    Some Message Here, its optional
    & stop processing the page. I you don't want to display a message, you can just simply call the function without passing it any string.

    But I think that you can create a nice "Website being Updated" page & use .htaccess file to redirect all page requests to that "Website being Updated" page. That'll be less resource heavy as while doing db updates, your visitors won't hit the db on every page load.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  4. #4
    SitePoint Member
    Join Date
    Nov 2004
    Location
    chile
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have the same problem and I like your solution, BUT,
    What is the ".htaccess file"?

  5. #5
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hiya,

    If you mean, what is a .htaccess file you can try reading this article.

    http://httpd.apache.org/docs/howto/htaccess.html

  6. #6
    SitePoint Member
    Join Date
    Nov 2004
    Location
    chile
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up .htaccess

    Thanks, now I know what for are those ".htaccess" files in my site that are created/updated by CPANEL( the managing software of my site) when I define redirection and/or password protection.

    Anyway, it also seems to me that defining a temporal redirection to a page explaining that is the best thing to do when I need to modify the site.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •