Click to See Complete Forum and Search --> : [RESOLVED] .htaccess question


comptech520
11-19-2009, 07:40 AM
Hi, I'm going to be upgrading a website and was hoping to allow 1 IP address to view it during the upgrade process (mine), and any other IP except mine to redirect to another page.

How can I do that with .htaccess?

opifex
11-19-2009, 10:44 AM
one option...


RewriteEngine On
RewriteBase /
#this is your the IP that you connect from
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
#this is the temporary landing page
RewriteCond %{REQUEST_URI} !/upgrading-site\.html$
RewriteRule .* /upgrading-site.html [R=302,L]

comptech520
11-19-2009, 01:18 PM
What does the bottom line do?

RewriteCond %{REQUEST_URI} !/upgrading-site\.html$
RewriteRule .* /upgrading-site.html [R=302,L]

opifex
11-19-2009, 01:53 PM
RewriteRule is the acutal directive that sends everybody that enters the site root "/" , except those who enter from your IP, to "/upgrading-site.html"... as set in the conditions (RewriteCond) that precede it.

Full explanation in the abridged .htaccess "bible" here at the Httpd Wiki (http://wiki.apache.org/httpd/RewriteRule)

comptech520
11-20-2009, 08:04 AM
Hi There,

My website is in PHP, this is my code and please see attached files. CONNECTING with my IP, it looks like the site loads PLUS upgrade.html

RewriteEngine On
RewriteBase /
#this is your the IP that you connect from
RewriteCond %{REMOTE_HOST} !^0\.0\.0\.0 #actual IP WAS here
#this is the temporary landing page
RewriteCond %{REQUEST_URI} !/upgrade\.html$
RewriteRule .* /upgrade.html [R=302,L]

opifex
11-20-2009, 07:53 PM
That is interesting!
Is your "upgrading" page static html or is it sharing dynamic code with the rest of the site?

I would love to replicate this!!!
Other IPs just see the "upgrading" page... right?

comptech520
11-21-2009, 06:47 AM
I figured it out!! Did a little research.

On top of having my ISP IP added to the list, I HAD TO add the IP that the website is on.

THAT WORKED!!!

opifex
11-21-2009, 09:59 AM
That does make sense.