August 1, 201115 yr how do i do a php redirect for muiple ip values where only the first octect (i.e. 192.168.1.98 fist octect is 192) 5 then the rest change
August 1, 201115 yr if(substr($_SERVER["REMOTE_ADDR"],0,3) == 192){ // do redirect here } That should do the job
August 1, 201115 yr if(substr($_SERVER["REMOTE_ADDR"],0,3) == 192){ // do redirect here } That should do the job Just remember, This method will work but for a local network only.
August 2, 201115 yr Just remember, This method will work but for a local network only. I wasn't aware of that as far as I was concerned it would work externally as well. It doesnt matter in this case as 192.168 is a reserved local network but just out of interest why wouldn't it work externally?
August 2, 201115 yr I'm sad enough to have studied CCNA twice I might have misinterpreted what Shaun was trying to say. What I was asking is why $_SERVER["REMOTE_ADDR"] would only work with local IP addresses? Wouldn't the following code which uses the start of a public IP work in the same way? if(substr($_SERVER["REMOTE_ADDR"],0,3) == 216){ // do redirect here }
August 2, 201115 yr I'm sad enough to have studied CCNA twice I might have misinterpreted what Shaun was trying to say. What I was asking is why $_SERVER["REMOTE_ADDR"] would only work with local IP addresses? Wouldn't the following code which uses the start of a public IP work in the same way? if(substr($_SERVER["REMOTE_ADDR"],0,3) == 216){ // do redirect here } Because the IP your useing is internal, If you was to upload this script to a server outside of your internal network the script could not see that your IP is 192.168.1.2, It would see an external IP such as 88.2.45.120 or something simler. (www.whatismyip.com) Edited August 2, 201115 yr by Shaun Childerley
August 2, 201115 yr Ah I see what your saying thanks for the clarification a bit of a slow moment me thinks! I thought you were saying that $_SERVER["REMOTE_ADDR"] just wouldnt work with external IP's
August 2, 201115 yr Ah I see what your saying thanks for the clarification a bit of a slow moment me thinks! I thought you were saying that $_SERVER["REMOTE_ADDR"] just wouldnt work with external IP's No it definatly works for external
August 2, 201115 yr // OT Holy crap. You've actually managed to cover CCNA 2 times and not know what internal and external ips addresses are - you seriously have to be kidding me? IIRC, in session 1 or 2 they go all over IP addresses, reserved addresses, DNS etc. in some detail. I know full well what the difference between between internal and external IP's are thanks... I'm an assistant network manager so I think it may be a necessity for me to understand them dont you! That really wasnt what I was asking if you actually look at what I said in my previous post it was simply a misunderstanding as to what Shaun was getting at.
August 2, 201115 yr // OT Holy crap. You've actually managed to cover CCNA 2 times and not know what internal and external ips addresses are - you seriously have to be kidding me? IIRC, in session 1 or 2 they go all over IP addresses, reserved addresses, DNS etc. in some detail. I know full well what the difference between between internal and external IP's are thanks... I'm an assistant network manager so I think it may be a necessity for me to understand them dont you! That really wasnt what I was asking if you actually look at what I said in my previous post it was simply a misunderstanding as to what Shaun was getting at. Perhaps stop bitching at each other?
Create an account or sign in to comment