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.



Comments

Popular posts from this blog

How to delete videos from your Youtube Watch History list?

How to Delete Individual or all videos from your Youtube Watch History list? Youtube keeps a fine record of the videos that you had watched earlier. You can view this by visiting the History section. If you want to remove the video's from the list do the following: Logon to Youtube and click on the "History" tab on the left menu to view Watch History ( Read more ) There will be check boxes corresponding to each video in the list Tick the check boxes of the videos which you want to remove Click on " Remove " button to delete the videos.

How to add "Link to this page" option under blogger posts?

Steps in adding Link to this page to your blogger posts Links to your page can improve your page rank. So it is a good option to add HTML code for linking to your web page. So that reader can copy and paste it on their web page. if another website links to your web page, this is considered an external link to your website. External links to your website are the most important source of ranking power and in SEO terminology it is considered as third party ranking vote for your page.

Intex Aqua 5.5 VR Plus genuine Review - Dont Buy Intex Aqua 5.5 VR Plus - Board complaint and low battery backup issues

Intex Aqua 5.5 VR Plus  Review - Dont Buy Intex Aqua 5.5 VR + - Board complaint and low battery backup issues I bought an Intex Aqua 5.5 VR Plus on April 23, 2018, With in a week it started to show Battery backup issues. Even if it is charged full, it will completely drain out with in 12 or 13 hours. During this time No internet was used, only 2 or 3 calls were done. Some times there was issues with net connection also.


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