views:

86

answers:

5

I have a static web page that I need to turn off, I don't want to delete the file though because there is a good chance I will need to turn it back on in the future. How can I do this?

Thanks!

+1  A: 

Rename / move it to a filename/folder that the web server will not serve (good point Richard)

SillyMonkey
... to a filename/folder that the web server will not serve.
Richard
+1  A: 

If you want the page to no longer be served, why not just rename it to file.html.disabled or something? When you want to continue serving it again, rename it back?

Rob Cooper
+2  A: 

You can use an .htaccess file to redirect it:

rewriteengine on
rewriterule ^static-page.html$ relocate-here.html [L]
Andrew G. Johnson
Is there a way to do this in PHP? ...not sure if its true but I heard adding too much to .htaccess can make your site run slow?
John Isaacks
Adding this line won't make your site load slow...
Andrew G. Johnson
Thanks for clearing that up AJ.
John Isaacks
No problem, and to be honest I'd do this just for the excuse to practice htaccess, it becomes really, really useful for SEOing your content and giving them language agnostic URLs which I really like
Andrew G. Johnson
+2  A: 

You should be having it in your source control(?) then remove it and add it when you need it. Or Rename it as Rob said.

Shoban
A: 

If the page you are wanting to temporarily 'hide' is a php page, you could do something like this at the top of that php file you want to 'hide'.

<?php 
header('Location: http://www.example.com/not_available.html');
die();
?>

Just replace the url after Location: to a placeholder page of your choosing.

There are other HTTP header tricks you could do, like returning a 404, 503, etc.

http://phpweby.com/tutorials/php/35

You could also use the .htaccess trick suggested by @andrew-g-johnson, using the .htaccess file shouldn't have much of an impact performance wise, especially compared to doing it inside PHP.

Redbeard 0x0A
Thanks..not sure if its true or not but from what I understand the .htaccess route impacts performance on whole site because the entire .htaccess file has to be read before each page loads but the PHP route only impacts performance on the particular page. If I am wrong someone please correct me. Thanks.
John Isaacks
An htaccess line won't cause any performance issues
Andrew G. Johnson