Tidying dynamic URL’s
A few years back, I came across a very nice article discussing how you would make a dynamic URL more palatable to a search engine and I made good use of its content for my online photo gallery. The premise was that URL’s looking like that below are no help to search engines indexing a website. Though this is received wisdom in some quarters, it doesn’t seem to have done much to stall the rise of WordPress as a blogging platform.
http://www.mywebsite.com/serversidescript.php?id=394
That said, WordPress does offer a friendlier URL display option too and you can see this in use on this blog; they look a little like the example URL that you see below and the approach is equally valid for both Perl and PHP. I have using the same approach for the Perl scripts powering my online phone gallery and now want to apply the same thinking to a gallery written in PHP:
http://www.mywebsite.com/serversidescript.pl/id/394
The way that both expressions work is that a web server will chop pieces from a URL until it reaches a physical file. For a query URL, the extra information after the question mark is retained in its QUERY_STRING variable while extraneous directory path information is passed in the variable PATH_INFO. For both Perl and PHP, these are extracted from the entries in an array; for Perl, this array is called is $ENV and $_SERVER is the PHP equivalent. Thus, $ENV{QUERY_STRING} and $_SERVER{‘QUERY_STRING’} traps what comes after the "?" while $ENV{PATH_INFO} and $_SERVER{‘PATH_INFO’} picks up the extra information following the file name (the "/id/394/" in the example). From there on, the usual rules apply regarding cleaning of any input but changing from one to another should be too arduous.
Other Posts That May Interest You
Place your comment
Topics Discussed
Adobe Apache Blog Blogging Canon Command Line CSS Debian Fedora Firefox GNOME Google hard drive Hardware Installation Internet Explorer Linux Microsoft MySQL Opera Operating System Perl Photoshop Photoshop Elements PHP plugin SAS Software SQL Ubuntu UNIX upgrade VirtualBox Virtualisation Virtual Machine Vista VMware Web Browsers Windows Windows XP WordPress WordPress.com WordPress plugins XHTML XPTwitter Updates
- Delicious: Squidoo : Welcome to Squidoo http://ow.ly/18mKhR 19 hrs ago
- Delicious: SAS software users Headquarters http://ow.ly/18mKhS 19 hrs ago
- Delicious: HTML Forms: jQuery Basics - Getting Started - http://www.htmlgoodies.com http://ow.ly/18mu5z 1 day ago
- Delicious: Enterprise Web Content Management Systems (CMS) | RedDot , now OpenText Web Solutions Group http://ow.ly/18kK8v 2 days ago
- Delicious: Content Management System CMS Reviews, CMS News, CMS Analysis http://ow.ly/18kEcm 2 days ago
- More updates...
Monthly Archives
[...] I wrote about tidying dynamic URL’s a little while back, I had no inkling that that would be a second part to the tale. My discovery of [...]