Re: 1 ip address go here all others go here
| From: | Ray Hauge | Date: | Tue, 13 Dec 2005 17:27:26 +0000 |
| Subject: | Re: 1 ip address go here all others go here | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-227396@lists.php.net to get a copy of this message | ||
Oops... REMOTE_ADDR should have been used.
Ray Hauge wrote:
That would be something along the lines of: preg_match("/^192\.168/",$_SERVER['REMOTE_HOST']); I'm a little rusty on my regex, but that should do it. Dave Carrera wrote:i know about $_SERVER['REMOTE_HOST'] but i think i should of said how do i compare any address starting with 192.168. sorry if my first question was to vague David Grant wrote:Try $_SERVER['REMOTE_HOST'] instead of REFERER. Dave Carrera wrote:Jay Blanchard wrote:[snip] Is there a way of sending users with a local ip address say 127.0.0.1 and 192.168.xxx.xxx to goto one page and all other visitors to goto another? [/snip] Yes, there is. $_SERVER['REFERER'] will give you the referer mosy of the time. More info from TFM can be found here; http://us3.php.net/reserved.variables Header can then be used to redirect header("Location: http://www.example.com/"); /* Redirect browser */. More info from TFM can be found here; http://us3.php.net/headersnip from TFM 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. notice the last 7 words !!!!