Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am trying to figure out how to create dynamic links and urls on a static webpage. What I want to do is the following:

I have a single webpage for example: MYWEBPAGEdotCOM/INDEX.HTML

that will always look the same, except for one link on the page. the link would be on the page for example:

LINK TO AFFILIATE: affiliatedotCOM/my-affiliate_code_here_DYNAMIC_REFERER

the only thing would change is the "DYNAMIC_REFERER" with every dynamic url on this page:

MYWEBPAGEdotCOM/INDEX.PHP_id=test1
MYWEBPAGEdotCOM/INDEX.PHP_id=test2
MYWEBPAGEdotCOM/INDEX.PHP_id=test3
MYWEBPAGEdotCOM/INDEX.PHP_id=test4

which would only hange the dynamic link on the page to:

affiliatedotCOM/my-affiliate_code_here_test1
affiliatedotCOM/my-affiliate_code_here_test2
affiliatedotCOM/my-affiliate_code_here_test3
affiliatedotCOM/my-affiliate_code_here_test4

Can someone tell me how I could go about doing this?

I just dont want to have to make 100's of pages, as this would prevent me from having to do so.

share|improve this question
add comment

2 Answers

Since your index is PHP, all you need is to modify the link using PHP.

So, in your index.php between the HTML you would have something like:

<a href="affiliate.com/my_affiliate_code_here_<?php echo $_GET['id']; ?>">Link Text</a>

So, when someone goes to: index.php?id=test1

The link would go to affiliate.com/my_affiliate_code_here_test1

That's it! Any script you would find to do this would me more hassle.

share|improve this answer
add comment

The referrer in PHP is in the _SERVER global.

echo $_SERVER['HTTP_REFERER'];

Set a variable in a separate file like $referrer = $_SERVER['HTTP_REFERER']; Include the file in whatever file you want to use this in.

I think this is what you are asking anyway.

share|improve this answer
    
I am guessing I am going to need a php script to do this. Is there any cheap or free ones out there that could handle this for me? –  John Jan 21 '11 at 23:23
    
If you have 100's of pages you should really be using a Content Management System like TextPattern, Modx or ExpressionEngine. They all automatically handle URL writing so you can focus on content. They all allow page design too so you can customize them to fit your design. –  Richard Testani Jan 21 '11 at 23:34
    
its just one page. I would have to make the same page multiple times, just changing the one link. I would like to make one page that changes the link with the variable in the url. that is what I am looking for. –  John Jan 22 '11 at 1:10
    
Set up an array with your page structure. –  Richard Testani Jan 23 '11 at 18:59
    
Sorry for the short reply above. - If it makes sense, do a associative array. Something like: $array = array('My Page' => '/my_page', 'Another Page' => '/another_page'); Then loop through the array and match the URL to a value in the array. –  Richard Testani Jan 24 '11 at 1:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.