Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

IP address redirect???

Thread Tools
 
Old Apr 1, 2003 | 07:27 PM
  #1  
ironwedge's Avatar
Thread Starter
Registered User
 
Joined: Apr 2001
Posts: 1,209
Likes: 0
From: Anchorage
Default IP address redirect???

Any of you web (HTML) gurus know if it's possible to put a redirect into the HEAD of a page that will only redirect certain IP address (or visitors from certain domains)?

I have a few pages that the FAA and Delta are using A BUNCH (users from xxx.faa.gov and xxx.delta.com on the server log) and I'd prefer that they didn't use so much of my bandwidth. Could I set up a redirect that would send only those IP/domains to say a porn site or something to make their work day a little more exciting?

I'm guessing it can be done, kinda like a browser sniffer action but look at the IP instead. I'm just not sure if it would be embedded in the page, or a SSI, or?

Thanks -
Reply
Old Apr 1, 2003 | 08:00 PM
  #2  
PeaceLove&S2K's Avatar
20 Year Member
 
Joined: Jul 2002
Posts: 19,257
Likes: 19
From: San Diego, CA
Default

Pretty easy to do with server side programming, and depending on what kind of server side technology you're using, I might be able to help you.

If your site is all static html, you'll still be able to do it via JavaScript. But visitors could just turn off javascript to get around your redirect, though.
Reply
Old Apr 1, 2003 | 11:01 PM
  #3  
The Unabageler's Avatar
Former Moderator
 
Joined: Oct 2000
Posts: 20,448
Likes: 0
From: internet
Default

use php or somethin...or you could use mod_rewrite if you're on apache
Reply
Old Apr 2, 2003 | 01:16 AM
  #4  
ironwedge's Avatar
Thread Starter
Registered User
 
Joined: Apr 2001
Posts: 1,209
Likes: 0
From: Anchorage
Default

Originally posted by PeaceLove&S2K
Pretty easy to do with server side programming, and depending on what kind of server side technology you're using, I might be able to help you.

If your site is all static html, you'll still be able to do it via JavaScript. But visitors could just turn off javascript to get around your redirect, though.
The pages are static HTML, no databases here. Using JavaScript, could I put an action in the HEAD of the page to do the redirect? Am I on the right track?

Thanks for the help!
Reply
Old Apr 2, 2003 | 01:18 AM
  #5  
ironwedge's Avatar
Thread Starter
Registered User
 
Joined: Apr 2001
Posts: 1,209
Likes: 0
From: Anchorage
Default

Originally posted by The Unabageler
use php or somethin...or you could use mod_rewrite if you're on apache
Thanks Josh, you urged me to learn php a while back....and I never did.

Maybe someday, I'll have the time (and mentors) to figure it out.

Cheers -
Reply
Old Apr 2, 2003 | 04:18 AM
  #6  
thunderchicken's Avatar
Registered User
 
Joined: Mar 2002
Posts: 1,457
Likes: 0
From: Zionsville
Default

No love for my ASP :-(

I don't know if php is the same, but you'll have their IP address, you may have to filter via that, and not the domain itself.
Reply
Old Apr 2, 2003 | 06:48 AM
  #7  
PeaceLove&S2K's Avatar
20 Year Member
 
Joined: Jul 2002
Posts: 19,257
Likes: 19
From: San Diego, CA
Default

I'm assuming SSI works on your webserver. If so, try this:

[CODE]

<script language="javascript">

var strRedirectURL = "http://www.goatse.cx";

var strRemoteHost = "";

var arrBannedDomainsRE = [/^.+.faa.gov$/g, /^.+.delta.com$/g];



for (var i = 0; i < arrBannedDomainsRE.length; i ++) {

Reply
Old Apr 2, 2003 | 10:32 AM
  #8  
ironwedge's Avatar
Thread Starter
Registered User
 
Joined: Apr 2001
Posts: 1,209
Likes: 0
From: Anchorage
Default

Too Cool! Thanks!

SSI do work on my server, so I added the script and no problems viewing the pages (any other errors) so far.

Thanks Again!
Reply
Old Apr 3, 2003 | 05:22 AM
  #9  
bzt0jc's Avatar
Registered User
 
Joined: Mar 2001
Posts: 44
Likes: 0
Default

Can the same script use for filtering or redirecting IE and Netscape users?

[QUOTE]Originally posted by PeaceLove&S2K
[B]I'm assuming SSI works on your webserver. If so, try this:

[CODE]

<script language="javascript">

var strRedirectURL = "http://www.goatse.cx";

var strRemoteHost = "";

var arrBannedDomainsRE = [/^.+.faa.gov$/g, /^.+.delta.com$/g];



for (var i = 0; i < arrBannedDomainsRE.length; i ++) {

Reply
Old Apr 3, 2003 | 06:23 AM
  #10  
PeaceLove&S2K's Avatar
20 Year Member
 
Joined: Jul 2002
Posts: 19,257
Likes: 19
From: San Diego, CA
Default

You mean will the script in both IE and Netscape? I think so, though I haven't tested it with Netscape.

If you mean you want to allow only users of browsers other than IE and Netscape to visit your site, you'll have to modify it slightly.

Also keep in mind that:
1. Person from faa.gov and delta.com will still be able to hit your homepage once before getting redirected. So while the number of hits from that domain will hopefully be reduced, it won't be eliminated.
2. The script does not prevent search indexing bots from visiting your site still (thus if that's the source of your increased bandwidth usage, this won't solve your problem)
3. Someone can turn off javascript on their browser to work around this script.

To truly block someone would require some server side work - modifying web server configuration, for instance.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
OverBooster
Off-topic Talk
2
May 17, 2004 06:45 AM
s2kdriver80
Off-topic Talk
11
Apr 11, 2003 02:31 PM
Skuzzy
Off-topic Talk
10
Jan 22, 2003 05:22 PM




All times are GMT -8. The time now is 09:26 AM.