htaccess - block all during site update

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
gwnterprises
Forum Newbie
Posts: 5
Joined: Sun Jul 26, 2009 1:30 pm

htaccess - block all during site update

Post by gwnterprises »

Hello,
I need to update some core files on my site and need to redirect all requests to my site with the exception of my IP address to a temporary index file (index.html) located at the root.

I tried to get help through my web host but can't seem to get a straight answer.

Here is what I have figured out so far, but as you can guess, my IP is redirected as well.
(This is just part of the .htaccess file)

RewriteCond %{HTTP_HOST} ^SITENAME.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.SITENAME.com$
RewriteRule ^index\.php\/?(.*)$ "http\:\/\/SITENAME\.com\/index\.html" [R=302,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^DIRECTORY1\/?(.*)$ "http\:\/\/SITENAME\.com\/index\.html" [R=302,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^DIRECTORY2\/?(.*)$ "http\:\/\/SITENAME\.com\/index\.html" [R=302,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^DIRECTORY3\/?(.*)$ "http\:\/\/SITENAME\.com\/index\.html" [R=302,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^DIRECTORY4\/?(.*)$ "http\:\/\/SITENAME\.com\/index\.html" [R=302,L]

Is there a way or code that I can insert into the .htaccess file that will allow just my IP address, so I can test for errors?

Thanks!
Wayne
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: htaccess - block all during site update

Post by Darhazer »

Code: Select all

RewriteCond %REMOTE_ADDR !^127.0.0.1$
RewriteRule ^(.*)$ http://yourdomain.com/tempfilename.html [R=302,L]
Replace the IP and address with your values
gwnterprises
Forum Newbie
Posts: 5
Joined: Sun Jul 26, 2009 1:30 pm

Re: htaccess - block all during site update

Post by gwnterprises »

Thanks Darhazer,

I try to find the answer on my own, a great way to learn.
I'll try to find a site/book/etc... for this type of language.

When all fails,this forum is a good place to get great help.

Thanks again
Wayne
Post Reply