Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Chit-Chat (http://www.chiefdelphi.com/forums/forumdisplay.php?f=14)
-   -   Web Page Help (http://www.chiefdelphi.com/forums/showthread.php?t=402)

mpking 24-07-2001 19:46

Web Page Help
 
Ok, I've bashed my head for the last few hours.

I'm trying make a simple redirect script for a web page

If your IP address begins with 207.206
goto http://this site.com
else
goto http://that.site.com

I don't care how it's occomplished (php, server config, java, javascript,etc)

It's on a apache 1.3.19 server that I have complete control over. I've spent the last couple of hours trying to do it with javascript, and everything I've come up with is Netscape only. Arrg!

Can anyone help?

Please?

Brandon Martus 24-07-2001 23:44

heres some php

PHP Code:

<?php

if ( strstr($REMOTE_ADDR'207.206') ) {
  
header ("Location: http://this.site.com");
  exit;
} else {
  
header ("Location: http://that.site.com");
  exit;
}

?>


I didn't test it out.
Let me know if it doesnt work, and I'll fix it.

mpking 25-07-2001 00:02

Um?
 
Um, how's this work.

I'm assuming the file has to be renamed from index.html to index.php?

Never dealt with PHP before?

Quote:

Originally posted by Brandon Martus
heres some php

PHP Code:

<?php

if ( strstr($REMOTE_ADDR'207.206') ) {
  
header ("Location: [url]http://this.site.com[/url]");
  exit;
} else {
  
header ("Location: [url]http://that.site.com[/url]");
  exit;
}

?>


I didn't test it out.
Let me know if it doesnt work, and I'll fix it.


mpking 25-07-2001 01:08

Re: Um?
 
Ok, I've enabled SSI on the server, turned on XBitHack, and made the page executable.

It was halfway working, but now it's not.

by halfway I mean this.
I should have been clearer in my example.

if 207.206
https://netreg.bridgew.edu/indexresnet.html
else
https://netreg.bridgew.edu/indexall.html

I had those two locations in there, and when it was partway working, it would redirect to the httpS, but it wouldn't pick up the document.

Adrian Wong 25-07-2001 21:22

Do you have mod_rewrite setup on your Apache server?

mpking 25-07-2001 22:42

Solution is Found
 
Ok, I called in one of the programming guru's at work, and in trying to explain it to him, I hit apon the solution.

The solution that I've discovered is a combination of Javascript and SSI includes.
Code:

<noscript><meta http-equiv="refresh" content="2; URL=indexresnet.html"></noscript>
<script language="JavaScript">
<!--
var resnetsTargetURL = "https://netreg.bridgew.edu/indexresnet.html";
var allsTargetURL = "https://netreg.bridgew.edu/indexall.html";


function doRedirect()
{
var ip = "REMOTE_ADDR";
if (ip.indexOf("192.168") >= -1) 
        setTimeout( "window.location.href = resnetsTargetURL", 2*1000 );
else
        setTimeout( "window.location.href = allsTargetURL", 2*1000 );
}
//-->
</script>

<script language="JavaScript1.1">
<!--
function doRedirect()
{
var ip = "REMOTE_ADDR";

if (ip.indexOf("192.168") >= -1) 
  window.location.replace( resnetsTargetURL );
else
  window.location.replace( allsTargetURL );
}

doRedirect();

//-->
</script>

of course the <body onload="doRedirect()"> tag is in there too.

Thanks for all your suggestions, you guys at least got me started on the right road.

mpking 26-07-2001 22:24

Ok, just a small minor update. The previous script I posted don't work.

I did a google search on SSI redirects

Came up with this script. Keep in mind this is the entire webpage.

Code:

<!--#if expr="${REMOTE_ADDR} = /192.168.10/" -->
<!--#include file="indexresnet.html" -->
<!--#else -->
<!--#include file="indexall.html" -->
<!--#endif -->



Kinda neat, eh?

The pages I want displayed are completely contained in the .html files.

Too bad no one had mentioned server side includes to me before. (they've been suppored since both browsers verion 2.0)

Brandon Martus 27-07-2001 05:11

oh yea :p

i mainly use SSI for

including files
<!--#include virtual="/file/to/include/here.html"-->

and executing cgi's
<!--#exec cgi="/cgi/date.pl"-->


forgot about the scripting capabilities.

Kyle Fenton 27-07-2001 10:48

Using Flash 5
 
You can use Flash 5 to re-direct to any file. It is simple and most people have the plug-in for it.


All times are GMT -5. The time now is 07:54.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi