Forum
htaccess re-write for Category URL's
I have a Perch category URL like this...
https://mysite/category.php?cat=products/demolition/
And want to change them to something cleaner like...
https://mysite/products/demolition/
something like this would work...
RewriteEngine On
RewriteRule ^([^/]*)/$ /category.php?cat=$1 [L]
The parameter of cat=products/demolition/ being a URL is pushing the link down the tree after cleaning up so the page cannot be found at that level as category.php it in the main directory. Or I think that's what happening
Are there any tips how this can be fixed. I'm having a blind moment.
How are you going to distinguish between
/products/demolition
and/about/offices
, for example?This is just for a single "product/type/" category set so there won't be anything else.
It's not entirely needed for this project just icing on the cake to tidy it up. Am I right in saying it's the slashes that's the problem here pushing everything into a different directory to the actual file.
Your pattern is matching anything that is not a slash. The thing you're trying to match contains a slash.