i am trying to use friendly url for my categories.
Example Database
cat_id | parent_id | name | url
1 0 cat1 cat1
2 1 cat2 cat2
My approach to do is to pass the parameter cat with url value for example show.php?cat=cat1
and in .htaccess i must rewrite to /cat1
BUT what about when i want to access cat2. I want to rewrite as cat1/cat2 so the parameter is show.php?cat=cat1/cat2 and then parse the value to secure that cat2 belong to cat1.
And so on.
I am not using MVC so i have to do it on my own.
Please if any other solutions is better please advice or suggest me reading
Thank in advance.
You already save the “url” in the database, I would say the simplest solution is to just put the complete category string (including parents) in that column of the database. That is:
Or is your question about the .htaccess syntax?