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 Blogging Blogs Canon Command Line CSS Debian Fedora Firefox GNOME Google Hard Drives Hardware HTML Installation Internet Explorer Linux Microsoft MySQL Opera Operating System Perl Photoshop Photoshop Elements PHP Plugins SAS Software SQL Ubuntu UNIX upgrade VirtualBox Virtualisation Virtual Machines VMware Web Browsers Windows Windows Vista Windows XP WordPress WordPress.com WordPress plugins XHTMLTwitter Updates
- GR Shared Items: Install Guest-Additions on Ubuntu 10.10 Beta : Workaround http://ow.ly/18VGtM 4 hrs ago
- GR Shared Items: Donncha: Easy Setup for WP Super Cache - One of the things that has bugged me about the WP Super Ca... http://ow.ly/18UbjE 1 day ago
- GR Shared Items: SD, SDHC and SDXC cards get speed injection http://ow.ly/18UbjF 1 day ago
- GR Shared Items: WP Blackberry: WordPress for BlackBerry 1.4.3 Released http://ow.ly/18UbjG 1 day ago
- Not before time: RT @pc_pro: Orange and T-Mobile to share networks from next month http://bit.ly/bhdXsu (Ah, bless) 3 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 [...]