Forum Moderators: coopster & phranque

Message Too Old, No Replies

How do I do this?

Involves redirect

         

ajs83

12:18 am on May 29, 2004 (gmt 0)

10+ Year Member



I am looking to add a redirect to my site and was wondering how i would need to do it to get the desired results. What I am looking to do is have a script that will allow me to post a link such as

http : // www.outsidesite .com /information/*varible*/return

which would then turn into this link

http : // www. mysite.com/redirect/go.php?http : // www.outsidesite .com /information/*varible*/return

then once clicked it would direct to

http : // service.blahblah.outsidesite .com /blah/blah/information/*varible*/return/

I understand on how to add the files to get a normal redirect going but don't know how to get it to insert the link variable into the right spot for the correct destination site (as their are a few and each varies). Any help or incite on this would be greatly appreciated!

MichaelBluejay

9:39 am on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What do you mean "post a link"?

volatilegx

5:47 pm on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your go.php file would read $ENV{'QUERY_STRING'} and print a Location header, e.g:

print "Location: $ENV{'QUERY_STRING'}\n\n";

<added>Oops I just noticed that "go.php" is a PHP file, not a perl script, haha. In PHP, you'd use:

Header("Location: ".getenv($query_string));
</added>

ajs83

8:35 pm on May 29, 2004 (gmt 0)

10+ Year Member



What I meant is if I post a link on the site with a variable (whether a number inside the link to a news article or product link) in there it would be able to catch the variable and add it to the appropriate spot so that the link works and it is able to send it via the appropriate link without doing each one manually.

MichaelBluejay

10:27 pm on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's four ambiguous pronouns in one sentence (it, one). I'm still not following you. I could probably figure it out if I re-read your post enough times but I'd prefer that you just be a little clearer. For example, I don't know what you mean by "turns into", nor why you have the word "return" at the end of your urls. Can you try starting this request over from scratch?

ajs83

8:00 am on May 30, 2004 (gmt 0)

10+ Year Member



Ok, I'll restate it, but for reference, what I am saying in earlier posts is

""turns into" = When I post the story, the link would automatically turn into that link

"return" = just an example url, probably not the best word to use.

-----------------------
What I'd like to do is to add a master link so to speak. If I or someone posted a link it would catch it and add in my redirect so if someone entered

[example.com...]

The site would pick it and add the following
in front of it

[mysite.com...]

The displayed and clickable link would then look like this

[www....] mysite.com /redirect/go.php?http://www.enteredurl.com
---------------------------------------
Next task

With that "master link" (http : //www. mysite.com /redirect/go.php?) in front of all links, how can i use the redirect to read the link and add the appropriate affiliate/referal link, if i have an account with that site?

So, if someone entered

[example.com...]

and I happen to have a referal/affiliate account with them, the redirect would see it's going to example.com, and send them via my customized affiliate/referal link?

[edited by: jatar_k at 4:40 pm (utc) on May 30, 2004]
[edit reason] generalized urls [/edit]

MichaelBluejay

6:42 pm on May 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok, I'll restate it, but for reference, what I am saying in earlier posts is

""turns into" = When I post the story, the link would automatically turn into that link

Already I don't understand what you're saying.

What I'd like to do is to add a master link so to speak. If I or someone posted a link it would catch it and add in my redirect

Again, all these gratuitous ambiguous pronouns don't help clarity. Instead of saying "it" say what you're referring to. I have something similar to dyslexia so when there's noise in the communication my comprehension clicks off.

so if someone entered
[example.com<...]

If *someone* entered? I thought *you* were the one "posting" a link?

I stopped reading at this point, I'm lost again.

ajs83

3:07 am on May 31, 2004 (gmt 0)

10+ Year Member



I'll try one more time.

What I want to do is the same thing this site (Webmaster World) does

When I type [example.com...] in, they add

http://www.webmasterworld.com/red.cgi?f=13&d=3639&url=

infront of the links. If you click the link it sends you through the redirecter first and then sends you to the site.

How do I do this on my site? I'm thinking it has to be placed somewhere in the .htaccess file but do not know where or what code to add.

bose

3:14 am on May 31, 2004 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, ajs83

MichaelBluejay

10:37 pm on May 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay! Now we're getting somewhere. Here's how to redirect a page with Perl.

Here's the HTML for your page:

<HTML><BODY><A href="/redirect.cgi?http://example.com">Go to Example.com</A>
</BODY></HTML>

-----------

And here's the Perl script ( the file <redirect.cgi>):

#!/usr/bin/perl -w

print "Location: $ARGV[0] \n\n";

At this point I assume you will have a followup question of some kind....