Search Engine Friendly URLs with Path_info and Mod-rewrite
Apache has a global variable called $PATH_INFO that is created
on every HTTP request, What this variable contains is the script
that's being called, and everything to the right of that information
in the URL. $PATH_INFO will contain article.php/12.
First you have to split this into variables you can use. And you can do that using PHPs explode function:
$var_array = explode("/",$PATH_INFO);
Once
you do that, youll have the following information:
$var_array[0] = "article.php"
$var_array[1]
= 12
rename the variable you get $var_array[1] as $article
if your artical has multiple page you can also get the page value here
article.php/12/1 explode this
$var_array
= explode("/",$PATH_INFO);
$var_array[0] = "article.php"
$var_array[1] = 12
$var_array[2] = 1
$var_array[1] as $article and $var_array[2] as $page_num
and get the value from database.
If you would like to remove the .php extention from article.php use below mehtod for that
Setting
up Apache to process a php file without an extension as a PHP
file.
In your .htaccess file (if you don't have one, create it), add
below code
<Files
site>
ForceType application/x-httpd-php
</Files>
There is an another option to make SEFu
Use Mod-rewrite
URL will look like
article.php/12
You can rename article.php to article and get it work as php file.
You can use following .htaccess file.
RewriteEngine
On
RewriteRule ^/article/([0-9]*) /article.php?ID=$1