Rewrite dynamic URL to static URL in PHP using .htaccess

When search engine visits the dynamic url site i.e http://sumitbansal.com/category.php?p=10, so it does not gives the more importance to this page because it keeps on chainging. So we convert the dynamic URL to static URL like:

http://sumitbansal.com/category.php?p=10  =>  http://sumitbansal.com/category/thisis-converting-url/

Example to make URL SEO friendly:

 First of all on the RewriteEngine

RewriteEngine On

Write a rule to Rewrite URL

RewriteRule ^category/([^/]*)/([A-Za-z0-9-]+)/$ category.php?id=$1&title=$2 [L]

This example will make this url ( category.php?id=1&title=2 ) to category/1/this-is-rewrite-url/

Explain:

^: pattern should match from the beginning of the string

(: start of subpattern

[^/]: write anything

*: one or more times

): end of subpattern

(: start of subpattern

[A-Za-z0-9-]: class of characters

+: one or more times

): end of subpattern

/: foward slash…

?: can occur zero or once

$: end of string


To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

Share This Post

Related Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie