Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP] How can I make a PHP maintenance page?

The World Is Yours
Loyal Member
Joined
Jun 19, 2007
Messages
1,668
Reaction score
147
EDIT
After I re-edited XZeenon's code, and uploaded my PHP files to my web-host it started working. It's Firefox that doesn't allow the code to work.

So thanks XZeenon!

----

Hello,

I was wondering how I can redirect users to a 'maintenance.php' page if in the index.php it shows "$maintenance = 1" and how I can show index.php if it shows "$maintenance = 0"

Can someone help me out here?:thumbup1:
 
Last edited:
WowIwasSuperCringeB4
Loyal Member
Joined
Jun 21, 2008
Messages
1,297
Reaction score
226
idk if this is how to do it im rusty on php bu there

PHP:
<?php
$maintenance = "1";

if ($maintenance=="1")
header( 'Location: http://www.yoursite.com/maintenance.php' ) ;
else
header( 'Location: http://www.yoursite.com/index.php' ) 
?>
 
The World Is Yours
Loyal Member
Joined
Jun 19, 2007
Messages
1,668
Reaction score
147
idk if this is how to do it im rusty on php bu there

PHP:
<?php
$maintenance = "1";

if ($maintenance=="1")
header( 'Location: http://www.yoursite.com/maintenance.php' ) ;
else
header( 'Location: http://www.yoursite.com/index.php' ) 
?>

Thanks for trying but the code didn't work for me. I also tried editing your code but it still didn't work. :(
 
WowIwasSuperCringeB4
Loyal Member
Joined
Jun 21, 2008
Messages
1,297
Reaction score
226
Thanks for trying but the code didn't work for me. I also tried editing your code but it still didn't work. :(

yeah for some reason it wont work but it should.
 
Skilled Illusionist
Joined
Apr 22, 2009
Messages
301
Reaction score
19
You could try :
PHP:
  <?php
$maintenance = "1";
    
if ($maintenance=="1")
    include("http://www.yoursite.com/maintenance.php") ;
else
    include("http://www.yoursite.com/index.php") ;
?>

PS: In the code you posted, it's missing a semicolon.
 
Junior Spellweaver
Joined
Jun 23, 2007
Messages
143
Reaction score
0
no its becasue your getting a loop

just use this mate

PHP:
  <?php
$maintenance = "1";
    
if ($maintenance == "1") {
    include("http://www.yoursite.com/maintenance.php") ;
}
?>

dose work i tested it :)
 
Joined
May 11, 2008
Messages
513
Reaction score
99
no its becasue your getting a loop

just use this mate

PHP:
  <?php
$maintenance = "1";
    
if ($maintenance == "1") {
    include("http://www.yoursite.com/maintenance.php") ;
}
?>
dose work i tested it :)
Also, I'd advise you using after you've included the mainteance.php
PHP:
  <?php
$maintenance = "1";
    
if ($maintenance == "1") {
    include("http://www.yoursite.com/maintenance.php") ;
// lets cut of the rest of the script :)>
    die;
}
?>
 
Custom Title Activated
Loyal Member
Joined
Aug 8, 2004
Messages
3,892
Reaction score
20
no its becasue your getting a loop
And the genius of the day award goes to coolep6 :laugh:

Your script was sending users back to itself. In firefox this is usually seen as an infinitely loading page, shortly followed by a 404 (page not found). IE generally just ignores the second header redirect close as I can tell.

Alternatively a much faster solution would consist of adding a .htaccess rule, provided you use an Apache webserver (IIS has a seperate module for adding these kind'a rules):
Code:
RewriteEngine on
# Comment out the next line if you want to stop redirecting.
RewriteRule !^(favicon\.ico|maintainance\.php) maintainance.php [L]
 
Back
Top