Quick URL Redirector

Just starting out? Need help? Post your questions and find answers here.
Slyvnr
User
User
Posts: 58
Joined: Wed Jun 27, 2007 10:10 pm
Location: USA
Contact:

Quick URL Redirector

Post by Slyvnr »

I am wanting to write a quick and simple program that will capture URLs submitted by the user and look in a simple textfile to see if it should be redirected.

Basically setting up an April Fools joke for NFL Draft Day.

Want to redirect the following sites

www.dallascowboys.com -> www.HoustonTexans.com
.
figure it would be best to enter the from and to into a simple text file so anyone can use it for any type of gag. Do not want to effect any other websites (i.e. yahoo. msn, espn, etc).

Format would be something like

siterequested, redirectedsite
i.e
www.dallascowboys.com, www.houstontexans.com


Basic program code is not the problem. THE PROBLEM:Trying to figure out a method to intercept from IE, Firefox, Mozilla, etc the URL requested and replace it/redirect it.

Thanks for any help,

Slyvnr
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Quick URL Redirector

Post by traumatic »

What about changing the hosts file?

(C:\WINDOWS\system32\drivers\etc\hosts on windows and /etc/hosts on linux IIRC)
Good programmers don't comment their code. It was hard to write, should be hard to read.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

You mention capturing url's from browsers.

If your program is not going to be the actual redirector, it would be simpler to just change the hosts file.

cheers
SeregaZ
Enthusiast
Enthusiast
Posts: 629
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Quick URL Redirector

Post by SeregaZ »

any idea how to make this redirector without editing this host file?
for example if i starting some atomic web server, and in this host file will be some redirect, like google.com to 127.0.0.1 - after shutdown this server google.com It is inaccessible. so it must be some procedure in program - that can return host file to normal, without redirecting.
and some antiviruses blocking editing host file.
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Re: Quick URL Redirector

Post by Matt »

Instead of getting what the webpage address is, what about simply looking for a window with the title "Dallas Cowboys - Home - Windows Internet Explorer" (or just with the first letters as "Dallas Cowboys") and then if that window exists either do one of two things:

1. This would be the easiest to code, close the window and open a new browser window with the new url.

2. Redirect the browser page. Possibly edit the text of the url field and then simulate a press on the Go button? Not sure. Is it possible to just access the actual browser element/gadget on the page and change the url that is being displayed?
SeregaZ
Enthusiast
Enthusiast
Posts: 629
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Quick URL Redirector

Post by SeregaZ »

if i try to redirect some java sript from another server? whole page is normal, but a few java script is bad. this redirect with host file swithcing this bad java for normal java script and whole page in browser will be without mistakes.
in this host file information about switching servers is open - anyone can to know what replace and where replase. how to make hide this redirect? that is why i want to know any ahother metod of redirection - very close to redirect in host file, but more hidden.
Post Reply