JustUser
JustUser

Reputation: 118

Create dynamic SEO friendly url in core PHP

I wanted to create seo friendly urls in core php, for example I have a category called Home and Furniture and in this category i am adding a product called Walton Sofa , assume that my domain name is www.mydomain.com.

If I create above category, my url should be www.mydomain.com/home-and-furniture and in this page all the products shouls be listed. If I create above product in same category, my product page url should be www.mydomain.com/home-and-furniture/walton-sofa this is product info page.

How can I create this kind of url in core php using .htaccess.

Here is what I tried,

To create category i was creating a folder(home-and-furniture) and to create a product i was creating a .php page in above named folder. So this is not good idea to create static folder and file.

Upvotes: 1

Views: 3915

Answers (1)

user5263205
user5263205

Reputation:

Add this code in your .htaccess

RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ product.php?pr_url=$1
RewriteRule ^([a-zA-Z0-9-/]+)$ category.php?cat_url=$1

Upvotes: 1

Related Questions