Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Php Redirect

Featured Replies

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

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.

 

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?

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
}

 

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 by Shaun Childerley

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 :fool:

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 :fool:

 

No it definatly works for external

// 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.

// 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.