• New Scripts
  • Popular Scripts
  • Top Scripts
  • Rss feed

Php Scripts

  • PHP Scripts
  • How to Add Link
  • Sponsor Listing
  • Login
  • Register
  • Getting Rated
  • Blog
  • Home
  • Subscribe to Feed
Blog > Tutorials > PHP Scripts > SEO Friendly URLs with PHP | mod_rewrite | .htaccess

SEO Friendly URLs with PHP | mod_rewrite | .htaccess

Posted on February 19, 2010, 7:20 am, by Scripts, under PHP Scripts.

In this tutorial I am going to explain the process ‘ How can we change the URLs in a SEO friendly URLs with the help of PHP, mod_rewrite and .htaccess in Apache’.

This is the very good and simple way to create a SEO friendly website with dynamic content.
Basically mod_rewrite is an Apache module and it takes care of rewriting URLs, like

http://www.example.com/page.php?id=2 convert in to http://www.example.com/page/2.html

To turn on the module use mod_rewrite in first line in htaccess using below line

RewriteEngine on

Now start with very simple htaccess.

RewriteEngine On
RewriteRule ^page/([0-9]).html$ /page.php?id=$1

Actual mod_rewrite rule is line 2.

RewriteRule ^page/([0-9]).html$  redirect to /page.php?id=$1

When you call the http://www.example.com/page/2.html it will call the dynamic urls

http://www.example.com/page.php?id=2

Here RewriteRule ^page/
([0-9])
.html$ call the number value which is ID in URL.

You can call multiple numbers on this rule like below

RewriteRule ^page/([0-9])/([0-9]).html$ /page.php?id=$1&pagenum=$2

After that URL look like below

http://www.example.com/page/2/3.html it will call the dynamic urls

http://www.example.com/page.php?id=2&pagenum=3

And you get the two variable

1. id
2. pagenum

You can call these variable and show the actual page results.

Tags: htaccess, mod_rewrite, PHP, SEO, SEO Friendly URLs
Comment (RSS)  |  Trackback

Leave a Reply

Click here to cancel reply.

Spam Protection by WP-SpamFree

« PHP include() file function & require() file function
PHP Scripts replace string str_replace() »

Categories

  • Announcements
  • Best Scripts
  • Tutorials
  • JavaScripts
  • PHP Scripts

Tags

htaccess image gallery include jquery mod_rewrite photo gallery PHP PHP Scripts radio button SEO SEO Friendly URLs show/hide str_replace() Tutorials

Web Hosting



Home | Feedback | Privacy | Advertise with us
(c) Copyright 2006 AdvanceScripts™. All rights reserved.
No part of this website may be reproduced, copied and/or distributed in any medium without express written permission
Trademarks are property of their respective owners
Site Developed and Hosted by Ethic Solutions