homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

link.php?URL Here
How do I do it

 3:43 pm on Jul 17, 2001 (gmt 0)

Hi Guys, (it's unusually quiet in here lately)!

Another question for my site, this one im sure is quite an easy one though. What I need is some way of having a script which lets me do the following:

Instead of having a URL [blar.com...] I would like to have a script which lets me have a URL like [blar.com...]

i.e. have a keyword which relates to a URL.
Im guessing this is the same sort of thing as having a download script which would do something similar.

Again, peeps, any ideas are welcome.




 4:12 pm on Jul 17, 2001 (gmt 0)

welcome, stickytape...
umm.. you might not know this, but having a "?" in your URL will prevent most spiders from indexing any further. Most of us make sure that dynamic pages appear static for that reason.


 4:16 pm on Jul 17, 2001 (gmt 0)

you're right, I didnt know that! Hmmm, anyway around this one? Any ideas people, I just think it looks more professional. Can someone supply me with a script anyways, so I can see the effect on my hits? Cheers


 4:19 pm on Jul 17, 2001 (gmt 0)

I'm guessing a little here, but is it that you want to redirect the user based on the parameter after the "?". I know how you can do this in perl (via writing a Location header) but i'm not sure how it would work in php.

As bartek says in any case it would thwart your SEO to a degree since SE's arent very keen on dynamic urls, so you would need something in place to rewrite the urls to static ones (e.g mod_rewrite).


 4:26 pm on Jul 17, 2001 (gmt 0)

This might sound really stupid, I don't know, but I just had an idea. Couldn't i write a txt file which listed all the keywords alongside the URL, then call this txt file when required.

Yes, Perlyking, the parameter after the ? is where I would want the user to be directed to, so for example index.htm?GoingOut would go to, for example GoingOut.htm or something alike.

Mod_rewrite, I've read a lot of stuff on WMW about that but I still am unsure as to what it is, or how to use it....any help??


 9:27 pm on Jul 18, 2001 (gmt 0)

I am not clear if this is what you are needing. If your index.php is going to direct the user based on the ? blar then you treat it as a "get" variable

index.php ? blar="blar.htm"


 10:42 pm on Jul 18, 2001 (gmt 0)

Stickytape: It looks like you might as well have a skeleton PHP page that based on its parameter reads a text file to fill in its contents. e.g the graphics a basic layout are always there and the php just loads and displays the text dynamically, say the parameter is goingout it reads goingout.txt and puts it into the page. I dont know any PHP really so maybe someone else can explain how that would work?

Mod_rewrite - theres a bit of a discussion here: [webmasterworld.com...] with an example that might help explain it, have a look using the search function for mod_rewrite and you will turn up a few more articles.

Hope this helps.


 6:43 pm on Jul 19, 2001 (gmt 0)

TPK - that's exactly what I need! I've read the stuff on mod_rewrite, hmm looks useful, but I really wanna do this in PHP, mainly because I'd like to test it on my Windows based computer first (Im using FoxServ with Apache installed) and then upload it to the linux servers. Basically, I cant run CGI or Perl I don't think. If anyone knows of how I can test perl or CGI on my Windows based machine, someone please get in touch. Nice one.

David - you're right, I read about that "get" variable last night. I know I can put it into a hyperlink, such as:
"<a href=link.php?Page=Blar>" which means when link.php loads it gives the variable 'Page', the value 'blar'. I get that, but what I need to know now is how to relate this, to displaying the "blar" data and not the rest..... ideas.... please... keep going guys, you're doing me proud so far!!


 6:52 pm on Jul 19, 2001 (gmt 0)

The simplest way would be via the include function:



 7:00 pm on Jul 19, 2001 (gmt 0)

so if I had that function in the URL, that would display the link.htm file?


 11:00 pm on Jul 19, 2001 (gmt 0)

In the link.phtml ? blar="1" always use a variable not the url you want to got to (it is more secure).

inside of link.phtml you then test with an if statement;

if ($blar == 1){

You should read about:
header files - (do's and dont's)
conditional statements - (you might like the "switch" statement for what you are doing)

hope this helps


 11:09 pm on Jul 19, 2001 (gmt 0)

Oh right, nice one. You know with your little bit of code;


say if my file was in goingout/file.htm - would this link then become



Also, I've just thought about this whole thing. Couldn't I just create a page with all my links in, like David has just described, for example:

if ($blar == 1){

if ($blar == 2){

if ($blar == 3){

and then link to each page with the appropriate number.

Would that work??

Cheers guys, this is top work!


 11:14 pm on Jul 19, 2001 (gmt 0)

That should get you off and running

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved