www.webdeveloper.com
Results 1 to 8 of 8

Thread: [RESOLVED] .htaccess question

  1. #1
    Join Date
    Apr 2005
    Location
    Behind my DiGiCo SD7 Console
    Posts
    900

    resolved [RESOLVED] .htaccess question

    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?
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html

  2. #2
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    one option...
    Code:
    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]
    ...but stupidity is terminal.

  3. #3
    Join Date
    Apr 2005
    Location
    Behind my DiGiCo SD7 Console
    Posts
    900
    What does the bottom line do?

    RewriteCond %{REQUEST_URI} !/upgrading-site\.html$
    RewriteRule .* /upgrading-site.html [R=302,L]
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html

  4. #4
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    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
    Last edited by opifex; 11-19-2009 at 01:55 PM. Reason: ...made it clearer???
    ...but stupidity is terminal.

  5. #5
    Join Date
    Apr 2005
    Location
    Behind my DiGiCo SD7 Console
    Posts
    900
    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]
    Attached Images Attached Images
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html

  6. #6
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    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?
    Last edited by opifex; 11-20-2009 at 08:00 PM.
    ...but stupidity is terminal.

  7. #7
    Join Date
    Apr 2005
    Location
    Behind my DiGiCo SD7 Console
    Posts
    900
    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!!!
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html

  8. #8
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    That does make sense.
    ...but stupidity is terminal.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles