In this post, we will see how to use .htaccess to create search engine friendly URLs. Using .htaccess, mapping dynamic pages to static address is easy and this helps search engines to index the pages fast, effective and strong.
Initially, create a file .htaccess in your favorite editor, use the rewrite rule as below to map dynamic id passing url's to static version. Use the code and create your dynamic pages for search engines spiders
**************************************************************
RewriteEngine on
## Rewrite Rules ##
RewriteRule ^category/([0-9]*)/([0-9]*)/([a-z_]*)$ category.php?id=$1&page_id=$2 [L]
RewriteRule ^category/([^/]*)/([a-z_]*)/([^/]*)$ category.php?r_name=$2&id1=$1
***************************************************************
For eg: Originally the page URL looks like subcategory.php?id=5&page_id=1
Using the above .htaccess code, you can create the URL as
category/5/1/product_name
Here,
RewriteRule ^category/([0-9]*)/([0-9]*)/([a-z_]*)$
^ - Refer to start
Category - creates a folder as mentioned name
/ - Used for virtual partition
[0-9] - Writes single number as folder name
[0-9]* - Writes n numbers as folder name
[a-z_] - Writes single letters as folder name
[a-z_]* - Writes letters as folder name
$ - Refer to end
Additional information:
Your id passing pages might have indexed through some referral and so, you can use the below code to avoid error pages, create a 404pagenotfound.php and add your a message to your visitors to navigate to home page for information’s
*****************************************************************
## Trace Errors
ErrorDocument 404 /404pagenotfound.php
*****************************************************************
Hope you will like the post and its useful :)
A to Z about Search Engine Optimization (SEO), a Internet Marketing Hand Book. In Jag's SEO a day help blog, SEO articles & tips are put together for free to educate SEO newbie’s, web designers, online business owners and seasoned SEO professionals. You're welcome to follow the blog for search & social media best practices. Thank you for visiting the SEO Help blog.
Thursday, May 08, 2008
Create Search Engine Friendly URLs using .htaccess
About Author
Jagadeesh Mohan Kumar Nambiar, commonly known as Jag, an SEO advisor who has been blogging since 2005, and has been in the field of SEO around 7 years, enjoys helping, teaching and recommends ethical SEO.
Jag is a moderator at SEWatch Forums, SERountable Forums, #3 Top pick Google Knol author and Blekko Associate Editor, more about Jag

Labels: .htaccess, Analysis SEO, Search Engine Friendly URLs, search engines spiders, SEO free advice, SEO Free tips
Subscribe to:
Post Comments (Atom)



4 comments:
Thanks just tried and works perfectly, bookmarked
i appreciate the tips. i also tried it and bookmarked the pages. great stuff!
It's something new,i will try it..Thanks!!
Very informative post.Thanks for your advice.
Post a Comment