Re-directing visitors to a temporary page?

I know that this has something to do with the .htaccess file that is found on the root of the server.

I am wondering how I can make visitors be re-directed temporarily to a page while my website goes under updating?

Re-directing using 301 looks too complicated for me and I don’t think it addresses what I am looking for as it seems like it is sending visitors to a completely new site i.e. domain

cssb,

You do NOT want to use a 301 (permanent) redirection!!!

Personally, I simply change the DirectoryIndex to index.html (which will provide my “down for maintenance” message) while I work on index.php and other PHP scripts which will be unaffected.

If you want to keep others off your scripts while they’re being worked on (I’d recommend you do this with a test server - OFFLINE - instead), you can redirect EVERY request (R=302, i.e., temporary) to index.html EXCEPT for your own IP address, i.e.,

RewriteEngine on
RewriteCond %{REMOTE_ADDRESS} !^127\\.0\\.0\\.1$
RewriteRule !^index\\.html$ index.html [R=302,L]

Be sure to use YOUR IP Address, not 127.0.0.1 which is “localhost”, i.e., your computer.

Regards,

DK

What do you mean my IP address? The IP address of the server or the one I use for using my internet?

OK, I think I know what you mean, the ip of my web domain

cb,

Nope, YOUR IP address with your ISP. Think of it as the IP address you want to give access to (yours!).

Regards,

DK

I don’t get it, you’re using localhost as an example, yet I have to use my computer’s IP? Strange

dklynn is suggesting a method whereby anybody trying to visit your site will be automatically redirected to the temporary page.

But presumably you want to be able to view your “under-construction” site without being redirected. So to do that, you have to set the IP address of the computer you’re using to be an exception to the redirect rule. In other words “redirect everybody to this page, unless they’re visiting from this particular IP address”.

Does that help?

Oh I get it now, thanks for that :slight_smile:

Thanks, TB. I must’ve had marbles in my mouth.

Regards,

DK

Anyhoo, I got tech support to do that for me, thanks for the help everyone

I am now having problems with a few links, though not all links while the site is being re-directed, i.e. maintenance mode

I keep getting “The page isn’t redirecting properly” (firefox), other browsers will come up with their own error messages, while testing site, this works well when on a localhost environment, but not on the remote server

the link goes to home.php but has ?key_word=art at the end

cb,

Make the redirection index.html? as the ? will remove any query string.

Regards,

DK

Meh, found the problem, me trying to be so smart and not using the old method of doing things, lol i.e. a script error thanks anyway for all your help in this matter