While developing dynamic websites in PHP you often encounter with dirty URLs (The urls that are not search engine friendly). Search engines love URLs in a clean manner. They prefer them either in .html form or without file extension.

For example here is an URL -
http://example.com/profile.php?username=techman&userinfo=blogs&pageno=2 
Such URL is  considered a non search engine friendly URL . Now look at this -
http://example.com/techman/blogs/2
This URL is more clean and understandable.  
In your dynamic website you create many URLs with query strings that are not user friendly. But , there is no need to worry you can create simple search engine friendly URLs by some small changes in your Apache Server configuration and .htaccess files.
Now , note down the steps-
Enable mod_rewrite for Apache
1) Find the “httpd.conf” file under the “conf” folder inside the Apache’s installation folder.
2) Find the following line “#LoadModule rewrite_module modules/mod_rewrite.so” in the “httpd.conf” file.You can do this easily by searching the keyword “mod_rewrite” from find menu.
3) Remove the “#” at the starting of the line, “#” represents that line is commented.
4) Now restart the apache server.
Now Here is URL Rewriting -

First of all add this line in your .htaccess file -
  Options +FollowSymlinks
  RewriteEngine on
Now we learn URL rewriting with some examples- 
Problem 1 :
Suppose I have  URL like 
http://example.com/profile.php?userid=techman
and I want  URL like 
http://example.com/techman 
I should add following rule in my .htaccess file -
RewriteRule ^([a-zA-Z0-9_-]+)$  profile.php?userid=$1


Problem 2 :


I have URL  – http://example.com/blogs.php?userid=techman&page=1
And I want a URL like – http://example.com/techman/1

I should simply add following rule in my .htaccess file -

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$  blogs.php?userid=techman&page=1