SEO friendly URLs without using apache’s mod_rewrite
Saturday, October 20th, 2007This tutorial shows how to setup SEO friendly URLs without using apache’s mod_rewrite.
Sometimes on large sites, mod_rewrite turns to be slow; hence overloads the server. So, here’s a tutorial to use SEO without mod_rewrite:
In the file which shows the content from the database, will have this code or a code similar to this.
Considering a URL: something.com/something.php?id=335
something.php will have this:
$article_id = $_GET[’id’];
$article=mysql_query(”SELECT article FROM articles WHERE ID=$article_id”);
print $article;
That’s just a simple code not for a use.
We want the URL something like this:
something.php/id/335
So for it, we modify the code in something.php to this:
$rq_dat=explode(”/”,$_SERVER[’PATH_INFO’);
now, the URL something.php/id/335
is broke in the script to
$rq_dat[’0′]=id
and
$rq_dat[’1′]=article id (335)
Now, we put this in the mysql_query()
mysql_query(”SELECT article FROM articles where ID=$rq_dat[’1′]”);
Isn’t it simple ?
The next problem is that we have the .php extension in something.php/id/335
To remove it, you have to setup a in the .htaccess file.
ForceType application/x-httpd-php
OR
ForceType application/x-php
OR
ForceType application/php5-script (php5 only)
Now rename something.php to something
It should work.
Note: This tutorial is published without any warranty. For any damage incurred, ecommercewebhosting.org OR any of its affiliates/authors will NOT be responsible. Use at your own risk
