Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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


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

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

The referrer in PHP is in the _SERVER global.


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

Your Answer


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