Skip to main content

HOW TO CREATE WEBSITES DRIVEN BY SEO FRIENDLY URLS WITH OUT USING HTACCESS

CREATING WEBSITES DRIVEN BY SEO FRIENDLY URLS WITH OUT USING HTACCESS

In this article I will explain how we can create websites which are driven by seo friendly urls with out using htaccess.

To read about SEO and HTaccess please read how to create SEO friendly url driven websites using HTaccess rewrite function

When we use HTACCESS for SEO friendly redirections, we use mod_rewrite module of apache. We can create seo friendly url driven site with out using the htaccess mod_rewrite module functions.

I will try to explain it very simple:

take this url path as example "http://www.myphpwebsite.com/"

for this you need a index file in the root folder
like this : http://www.myphpwebsite.com/index.php

The content for this page will be populated based on a parameter "content"

like this : http://www.myphpwebsite.com/index.php?content=home

so content of this page changes as the parameter value changes, the contents may be driven from database or include files

sample calls
http://www.myphpwebsite.com/index.php?content=home
http://www.myphpwebsite.com/index.php?content=contact-us
http://www.myphpwebsite.com/index.php?content=vacancies


so if you can fetching contents from the DB, you will be fetching contents from the contant table based on the supplied parameters
OR
You will be showing contents by including a file which is identified by the  supplied parameters.

for example when you call
http://www.myphpwebsite.com/index.php?content=home

you will be including a file like "home.php" into the main page ie, "index.php"


if( is_file("includes/home.php") )
include_once("includes/home.php");
 else
include_once("includes/page-not-found.php");
?>


Dont think I had diverted from the point....:)  I am coming to it..

Actuall trick starts from here

I am explaining the stuffs based on an assumption that out Main page "index.php" is using one parameter and the way it uses the param plays the trick of feeling like SEO friendly Urls.

You have to set the directory Index of your root folder to index.php.

You can refer index page like
http://www.myphpwebsite.com/index.php?content=home  
and also like
http://www.myphpwebsite.com/?content=home

I am using the second way for adding the trick ie
http://www.myphpwebsite.com/?content=home

when we access this parameter through Global Variable  as $_GET['content']

echo($_GET['content']);   will display  "home"

For applying trick we can use parameter value as the Parameter

like

http://www.myphpwebsite.com/?home

so Let see how it can be accessed in the main page  "index.php"

For proper working of the following code, the file name of the included file and the supplied parameter key should be same.

like , if you call http://www.myphpwebsite.com/?contact-me
then, there should be a file named "contact-me.php" in the "includes" folder and the file location will be like:
http://www.myphpwebsite.com/includes/contact-me.php



save the following code as index.php
in the code below i assume the  contents in the index.php are  included from "includes" folder at location
http://www.myphpwebsite.com/includes/

//code starts here   

<?php

// php section of the file

$my_title="Home : My Php Website";
$my_page="includes/home.php";

if( isset($_GET) && trim( key($_GET) )!="" ){
$my_page=strtolower(trim( key($_GET) )).".php";

if( is_file("includes/".$page) ){
$include_page = "includes/".$my_page;
$my_title=ucfirst(str_replace("-"," ",trim(key($_GET)) ));
}
else $include_page="includes/page-not-found.php";
}

?>

<!-- Html section of the file-->
<html>
<head>
<title><?php echo($my_title);?></title>
</head>
<body>
<?php
include_once($include_page);
?>
</body>
</html>

//code ends here 

Its Done. Now take your page http://www.myphpwebsite.com/

you can call other pages like

http://www.myphpwebsite.com/?home
http://www.myphpwebsite.com/?contact-us
http://www.myphpwebsite.com/?vacancies



Here I had used only single parameter to define the pages, you can modify the script and make it as multi param driven.



Popular posts from this blog

How to apply for a new ration card and what are the documents required?

List of documents required for new ration card application in Kerala and how to apply


Application for a new ration card should be addressed to Taluk Supply Officer (TSO) / City Rationing Officer (CRO) of applicant's residing area.

Primary document required are Residence certificate, Income certificate and incase the applicant's name is in another ration card then he/she should submit the reduction certificate ontained from previous TSO / CRO as proof for removing his/her name from old Ration card.

You can get the new application from your currently residing Taluk Supply Office.

Payback Points - How to redeem - How to merge multiple payback accounts - Block Payback card - Payback customer care

Joomla and Forum Integration - Integrating Forums to Joomla

Joomla is one of the most popular CMS opensource packages. It is very easier to develop website's using Joomla. You just need to download Joomla package from Joomla's Official website www.joomla.org  and install it on your domain and later adding customizations to templates and feature and Your website is ready :). Now a days most websites provides a forum section for it users for discussing various article topics, gathering opinions etc.



Following are some best know forum opensource packages which can be integrated with Joomla and create a new forum experience for users


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog