views:

246

answers:

3

Hi! I wanted to know if there is some way to change something simple, such as a htaccess file, a js file, or a php file, and then all of the webpages on my site will show an under construction page. I do not really care all that much if the user has to be redirected, but I want the origonal url of the page to be displayed in the address bar (not the one of the Under Construction page) and I want the user to be redirected before anythign else is executed, such as JS functions, or even the page loading.

Any help would be greatly appreciated!

Thank you!

--EDIT--

Ok, so I have figured out how to redirect the user, and it works great. Now, my only problem is, how do I make the url of the under construction page, appear as the original page? What I want to do, is if the user goes to mysite.com/page.html, I want the user to be redirected to mysite.com/underconstruction.html, but I want them to see mysite.com/page.html as the address in the address bar. Any ideas? I am not so sure about the mod_rewrite. I am looking up a few tutorials right now, but I am just learning how to edit the htaccess, and mod_rewrite seems a bit complicateed for a beginner, so if you dumb it down a bit for me, it would help out alot.

A: 

Put his in your .htaccess file

#Turn on mod_rewrite
RewriteEngine On
#dont redirect if we are at the maintenance page already
RewriteCond %{REQUEST_URI} !^/maintenance\.
#redirect to temporary page for any page matching our Rewrite Condition
RewriteRule /*$ /maintenance.html [L]
sberry2A
+2  A: 

We use apache mod_rewrite for this. It checks to see if a maintenance.html file exists, and it it does, serves up that page.

To turn it on, we just do:

> mv maintenance.html.bak maintenance.html 

and to hide it again:

> mv maintenance.html maintenance.html.bak 

Here is out httpd.conf for this:

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
Andrew Kuklewicz
A: 

htaccess is definitley the way to go.

At least it fullfills your "I want the user to be redirected before anythign else is executed, such as JS functions, or even the page loading".

I can't say for sure if it will display the original URL, you'll need to try that out.

Personally, my whole site is PHP and each page is a template, which includes header.php, css.php, menu.php, and footer.php, so a (possibly one line) change to common include file is all that I would need. I only mention it since you seem to be totally redesigning your website and might want to consider doing something similar (if you are not keen on raw PHP, look at a tempalting system like Smarty)

Mawg