Continued from page 1
If you want to go ahead and shorten URL even further, you can even use letters "F" and "L" instead of firstname and lastname.
For example, try this in your page:
And then use this URL (substituting with your correct URL, of course):
The result is same. I think we want our URLs to look a little better, though.
The format I used in that above example was:
Now, problem with this is that this link looks really ugly. Another setback with this format is that anything to right of "?" won't be indexed by some of smaller search engines.
Here's a way to change this:
It's really easy. Just change your script to this:
$myvars = explode("/",$REQUEST_URI); for ($i=0;$iecho "$f $l";
And in just a few lines of code, your personalized PHP script's URL just looked a whole lot better.
I won't bore you with details of what that script does, but it basically chops up URL you gave it and picks out pieces it wants using array exploding and variable-variables.
This snippet can also be used on almost any PHP script as well. (I used this method when I coded Brian Garvin's Lightning Track ad tracker... if you ever see a URL anywhere with "go.php/etc" in it, that's my script.)
Hopefully we all learned something today. This mini-tutorial was brought to you by letters "P-H-P."
Article by Robert Plank
Subscribe to the free opt-in newsletter "JumpX E-Magazine" for lots more PHP help.