homepage Welcome to WebmasterWorld Guest from 54.243.13.30
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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
stickytape




msg:1250318
 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.

Rich

 

bartek




msg:1250319
 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.

stickytape




msg:1250320
 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

theperlyking




msg:1250321
 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).

stickytape




msg:1250322
 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??

David




msg:1250323
 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"


theperlyking




msg:1250324
 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.

stickytape




msg:1250325
 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!!

sugarkane




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

The simplest way would be via the include function:

<?
include("$page.html");
?>

stickytape




msg:1250327
 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?

David




msg:1250328
 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){
header("location:/yourfile.phtml");
}

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


stickytape




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

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

header("location:/yourfile.phtml");

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

header("location:/goingout/file.htm");

???

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){
header("location:/yourfile.phtml");
}

if ($blar == 2){
header("location:/yourfile2.phtml");
}

if ($blar == 3){
header("location:/yourfile3.phtml");
}

and then link to each page with the appropriate number.

Would that work??

Cheers guys, this is top work!

David




msg:1250330
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved