Thursday, July 30, 2009

Redirecting URL with C++?

Hi,


I want to make a program that would redirect a person to one URL if they typed in a certain address.





For example, they enter:





www.domain1.com





It would redirect them to





http://www.domain2.net





The problem is that I have NO idea where to start. I don't know any functions or anything that could help accomplish this. Also, do I have to include something called windows.h? Everybody includes that in their C++ program when performing things in Windows, and I thought I might have to do that too.





Can anybody point me out to functions or anything that retrieve an entered URL, and redirect that person? Thanks.





NOTE: I want to make a standalone console program or desktop application (but not that complex), not some CGI program or Apache module. I asked this question earlier, but apparantly, I wasn't clear enough.





I will be determining this by simply putting the URL in the program.

Redirecting URL with C++?
Read the article on codeproject..





http://www.codeproject.com/library/lyoul...
Reply:there are websites that do that already like freedomain.co.nr .tk and 2ya.com there would be alot of competion but to first start out buy a domain. i have a website i use freedomain.co.nr's redirecction my sites amazingcodes.co.nr
Reply:There's no need to do this in C++ you can do it in HTML with a meta tag. If this is homework, it just goes to show what rubbish they teach nowadays.





If not, the meta tag would be:


%26lt;meta http-equiv="refresh" content="0; URL=http://place-you-want-to-redirect-to...
Reply:Let's analyze your post:





%26gt; I want to make a program that would redirect a person to one URL if they typed in a certain address.


Nice. But what do you mean by typing in an address? Do you have a web browser program here? A console program that opens up a web browser? What? And what do you mean by redirect? Are you handling http requests? Just taking a URL in console and displaying a different one? What?





%26gt; The problem is that I have NO idea where to start.


Probably by figuring out what sort of program you are writing first. "Redirect" sounds fine in non-technical parlance, but when it comes down to details, you need to be specific about what happens. What are you getting. What does type in mean? How is this URL being received?





%26gt; Also, do I have to include something called windows.h?


Only if you use Win API functions.





If all you are doing is taking a URL in input and displaying a different one in output, then you just need some algorithm to determine the new URL. How are you getting this new URL. If I type in example.com, why do I get anotherexample.net and not maryhadalittlelamb.com or not theskyisfallingdown.com? What logic are you using here? A lookup table? A set of rules? What?





EDIT:


I'm not showing off here. My questions aren't rhetorical. I can't answer your question unless you give more details. What do you mean by redirect? Do you intend to respond to an HTTP request appropriately? Are you just showing console output? And really, I need to know how the logic works. How are you getting a new URL from the old? If you had to do it by hand, how would you do so? These are serious details that have to be figured out ---before--- programming. Which you haven't answered quite yet. Here's a hint: describe what you want without using the word redirect.


No comments:

Post a Comment