indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : ServerSide
This Article...
Print Version
Add Comment
View Comments
ServerSide
Apache on Linux
Apache User Directory Configuration
PostgreSQL Configuration
CGI: What and How?
PHP Jump Start Guide
Arrays in PHP
PHP and HTML Forms
Variable Passing in PHP
PHP 'include'
Drop-down Menu Navigation in PHP
Edit Your Site Online Using PHP
PHP MySQL Polling System
Dynamic, Search Engine Friendly Pages
Quot Ticker Using SSI
Regular Expressions Reference
PHP File Browser
PHP DB Deletion/Approval Script
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

Dynamic, Search Engine Friendly Pages

The procedure described below was tested on a RedHat7.2 system running Apache web server.

You have to digest some bitter facts. Most search engines do not index URLs having the characters `?' & `='. It is standard practice to generate thousands of pages using just one template page. Such dynamic generation (from database, XML repository or any other source) traditionally required the use of `?'. The value after `?' in a URL is available as a CGI variable. So a single template page with different arguments would generate different pages.

So how do you generate dynamic pages, without making them search engine unfriendly? Consider this URL:

http://foo.com/template.php?var1=val1&var2=val2

This definitely is not search engine friendly. So you re-write the URL as:

http://foo.com/template.php/val1/val2

Using PHP you can process the above URL thus:

$tmp = explode($REQUEST_URI,"template.php/");
$vars = explode($tmp[1],"/");
$var1 = $vars[0];
$var2 = $vars[1];

Isn't that simple!

Additional Modifications

Doesn't `template.php' show off that it is a script file? Shouldn't we camouflage it so that it looks just as a directory? If you have `.htaccess' enabled in your Apache server, you can just do that!

Create a file `.htaccess' in the same directory where you place `template.php' with the following contents:

<Files template>
ForceType application/x-httpd-php
<Files>

Now rename the file `template.php' to `template'. `template' will be parsed as a PHP file. Now your URL looks more sexier:

http://foo.com/template/val1/val2

That is not the only thing Apache offers! You can also completely hide the script name:

http://foo.com/val1/val2

But this is a more complex procedure dealing with the Apache module MOD_REWRITE. Explaining this is beyond the scope of this article.

- Subhash
Sep.`02


User Comments

Add Comment

[Quick Stats: Number of main threads: 1, Number of sub-threads: 0]


Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.