Click here to Skip to main content
13,143,008 members (54,786 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to make small application that will redirect the particular url to another url when my application is running on that pc..
if i type
then browser should go to
i find a lot but didn't get appropriate answer. and vc++ both suggetion are welcome...
Posted 10-Jul-11 19:17pm
Updated 10-Jul-11 19:18pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Ashish Tyagi 40 11-Jul-11 9:54am
good link, my 5
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I guess you already have that list of blocked sites and you are writing code for block them and redirect to your default redirecting site..

It is a very basic functionality of a standard firewall...

Well for blocking or allowing any site requested from the browser you must capture those request and take action... and i think you already wrote the code for this, it is a firewall program actually. (If you are having problem in writing firewall then ask me)

For redirection there is a HEADER in HTTP specification called LOCATION you need to set this header by your desired redirecting site like "" in your response.

Otherwise you can use meta redirect. (Which is easier way...)

<title>Your Page Title
<meta http-equiv="REFRESH" content="5;url=">

Optional page text here.
this site is blocked and you are redirection to

Here 5 indicates how many seconds you want to wait before redirect, meanwhile you can show a message that, this site is blocked and you are redirection to

Good Luck Wink | ;-)
kadvanimayur 11-Jul-11 4:28am
Actually i m not too much can you give me code sample of firewall?
and by the way thank you..
Ashish Tyagi 40 11-Jul-11 4:44am
ha aha ha ... No problem...
First tell me do you know something about socket programming. It is all about it...

Reply first, .. then i will tell you how web browser works how to make http proxy and firewall..
kadvanimayur 11-Jul-11 4:58am
ya. i worked with socket programming and multithreading as well.. but i don't know how to work with internet..
Ashish Tyagi 40 11-Jul-11 6:48am
Hey If you know about both of these, then you have done half of your work for rest, please refer my another post below this...
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Ok all you need-
1. Configure web browser to connect internet through your program. If you are using internet explorer then Goto tools internet option Connection LAN setting check "use a proxy for your LAN and put; in place of Address: and 8080 (or whatever you want) as port no. After this when you click on any link or go to any address then your browser will attempt to make a connect on IP:PORT you configured.
2. Create a server socket and start listening on port 8080 (or what ever you configured). Accept connect from web browser and read all data from client socket (It is data sent by web browser), now you have a HTTP request. for reading this 4k buffer is sufficient.
3. Now parse this request and get the value of HOST: header it must look like "Host:" (read HTTP specification for the HTTP request format). Hint for parse it look for the index of ;host:" or "Host:" or "HOST:" and copy data starting from Host: and till the "\r\n". Trim the content.
And now you got the desired host name.
4. Now you have 2 cases
A. This host name is in your block list.
What to do :-Take these lines into a buffer

<html><br />
<head><br />
<title>Your Page Title</title><br />
<meta http-equiv="REFRESH" content="5;url="></meta></head><br />
<body><br />
Optional page text here.<br />
This site is blocked and you are redirecting to<br /> in 5 seconds<br />
</body><br />

and write that buffer to the client socket (socket for browser). Now browser will redirect page to in 5 seconds.

B. This host name is in your block list.
What to do :- create a client TCP socket connect to the host which you just parsed write the HTTP request to it and read the response. now write this response to the socket for web browser and browser will render the page.

If you found any difficulty to understand or implement it feel free to ask and once you write basic program then i will tell you about some design related optimization
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

i got NtTdiapi to get system level access and block the request on the computer itself and redirect that request..
Ashish Tyagi 40 14-Jul-11 12:13pm
Ok, well good luck with that but, but why you undo the answer Accepted. Any way I all the best for youe learnings. ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 14 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100