SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Shaw AFB
    Posts
    282
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess Restrict by IP

    I'm trying to figure out how to restrict my home page so that only my IP address can access index.php. I don't want to completely shut down my site to other tho. Here's what I have in mind.

    If the IP address is mine, go to index.php
    All others are redirected to index.html
    ~ Nate L ~

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Nate,

    What you're trying to do MUST (if mod_rewrite is used) is to use Apache's {REMOTE_ADDR} variable, i.e., the IP address of the visitor. To do this:

    1. Make your DirectoryIndex index.html index.php

    2. Test whether the {REMOTE_ADDR} is your IP address

    3. Redirect (if your IP) to index.php

    Show me your code and I'll help clean it up - examples in my signature's mod_rewrite tutorial.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

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