redirection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lionel
    Senior Member
    • Apr 2001
    • 688

    redirection

    I am using an .htaccess directive to protect entire folders, allowing access only to a range of IP within the intranet.

    Order Deny,Allow
    Deny from all
    Allow from 192.168.2.0/24
    ErrorDocument 403 /redirect.php


    I'd like to do the same for one vb file: register.php. Placing the code below requires that I would have to put in 250 IP.

    $ipaddy = getenv ("REMOTE_ADDR");
    if ($ipaddy != "the ip") {
    header("location:http://site.com/page.htm");
    }


    Is there an easy way to do it in PHP?
  • merk
    Senior Member
    • Jul 2001
    • 4149

    #2
    Pretty much what you did would work, but you can skip one step.

    i just re-read your post and to do it on just register.php in vbulletin,


    Place this into your phpinclude_start template.

    PHP Code:
    if(getenv('REMOTE_ADDR') != 'IP ADDRESS' AND THIS_SCRIPT == 'register')
    {
        
    header('Location: good.html');

    Comment

    • Lionel
      Senior Member
      • Apr 2001
      • 688

      #3
      That does not work at all. Mine does. My problem is I'd have to do it for 250 IP

      Comment

      • Lionel
        Senior Member
        • Apr 2001
        • 688

        #4
        never mind... I did it with .htaccess

        Comment

        • Icheb
          Senior Member
          • Nov 2002
          • 1291

          #5
          If you want to only allow a certain IP-range, do this:

          PHP Code:
          if(strpos($_SERVER['REMOTE_ADDR'],'123.123.123')!==false) {
             
          // proceed

          Note the !== operator is intentional since != won't work as expected.

          Comment

          • Lionel
            Senior Member
            • Apr 2001
            • 688

            #6
            it is a thousand times easier to use .htaccess and 100% foolproof

            Comment

            • Icheb
              Senior Member
              • Nov 2002
              • 1291

              #7
              Well, you wanted a PHP-solution, I gave you one.

              Comment

              • Lionel
                Senior Member
                • Apr 2001
                • 688

                #8
                Thanks, I really appreciate it.

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...