Dynamic Pages from URL's

Status
Not open for further replies.

Diorex

Chasing the long tail
Dec 7, 2006
349
10
0
Tejas
Longtime lurker, first time poster....I am horrible at web designing and was hoping someone could help me solve an issue.

I am trying to insert some content on landing pages to help me pass Yahoo's editorial review.

In the past I managed to buy keywords/city combos by simply putting the city name on static landing pages. No problem when you just want to buy a half a dozen keywords.

I now have a list of several hundred things and I just dont think creating several hundred static pages makes any sense at all.

What I want to do is insert a keyword that is pre-loaded into a URL such that the webpage loads and populates the keyword in certain areas based on a value in the URL.

For example - I sell 3000 flavors of Ice Cream and bid on those keywords. I want to create a URL like www.example.com/default.html?flavor=Chocolate

Then on my web site, I want to capture that flavor and dynamically insert that in my page in 2-3 spots. Like a Title that is "%Flavor% Ice Cream Sold Here." and maybe in my text with something like . "My Ice Cream store sells the best selection of %Flavor% ice cream in Timbuktu."

This way if I add 5 new flavors to my pretend ice cream store. I can just create URL's inserting the flavor and be ready to go.

So my 2 questions are:

1. What is the proper URL structure to accomplish this?
2. Is there an easy copy and paste javascript/asp/html/etc. code that I can use to grab that variable and insert it into my web pages based upon the URL.

I have tried to google this and was surprised I could not find an answer, may be that I was just using the wrong descriptions in my search. Anyone have any code that can do this or hints as to where I might be able to teach myself to do this.


Thanks in advance for any help!
 


A 3rd question....

Thanks, I will see if I can make that work.

Guess I have a third question then.

3. Once I have captured the flavor data, what is the proper method of inserting it into text?

<Title>
???
ice cream - sold here
</Title>

What would I replace the ??? above with to insert the variable
the URL passed.

4. Ok a 4th as well, where on the page is the prefeered placement for the php code?

Thanks!
 
PHP code is inline - just put:
<?= htmlentities($_GET['flavor']) ?>

whereever you want that variable to be shown.

ex: <Title><?= htmlentities($_GET['flavor']) ?> ice cream - sold here</Title>
 
In addition, if you want the pages to look like static html-files, you can use mod_rewrite to rewrite something like chocolate.html to default.php?flavor=chocolate.

Mod_Rewrite Tutorial
 
Status
Not open for further replies.