For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Thursday, March 12, 2015

Url rewriting in Php

Very simple Url rewriting in Php
Suppose you have a website and you are operating it with query string as below:
http://www.yoursite.com/computer.php?company=asus&name=s56c

you are using two query string "company" and "name". In "company" you are passing "asus" on the other-hand in "name" you are passing "s56c". So the question is that how to convert

"http://www.yoursite.com/computer.php?company=asus&name=s56c"
                                   TO
"http://www.yoursite.com/computer/asus/s56c.html"

The url "http://www.yoursite.com/computer/asus/s56c.html" is not SEO friendly. so how to make it SEO friendly?

It is very simple. for this you need to create ".htaccess" in the root folder where your site's  files existing. paste listed below 3 lines in ".htaccess" file.


Options +FollowSymLinks
RewriteEngine on
RewriteRule computer/(.*)/(.*)\.html computer.php?company=$1&name=$2


And this is the content of your "computer.php" file

<?php
$company=$_GET['company'];
$name=$_GET['name'];
echo $company."--".$name;
?>

open the computer.php as "http://www.yoursite.com/computer/asus/s56c.html"
Share:

0 comments:

Post a Comment

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive