Home  Shared Hosting  Reseller Hosting  Support Center  Review  Special Offers    

  join Affiliate Program

  

 Cheap Hosting
 
  
$9.99 /year
 Reseller hosting program
 Reseller Hosting
  
$9.99 /mo
We Accept all major Credit Cards and PayPal Also
Account Menu
  Home  
  My Cart  
  Create Account  
  LogIn  

Domain Services
  Register Domain  
  Register .NAME  
  Transfer Domain  
  Whois Lookup  

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 PHP’s explode function:

$var_array = explode("/",$PATH_INFO);

Once you do that, you’ll 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


Back

 



  Useful Resource  FAQ  About us  Contact us  Terms of Use  Acceptable User Policy  Privacy Policy     
© HostingOption.com
We Accept all major Credit Cards and Paypal Also