I've been banging my head since many hours on this and I am unable to come up with a solution.
What I need to get done.
- domain.com/page.php => domain.com/page/
- domain.com/category1-name1.php => domain.com/category1/name1/
- domain.com/category2-name1.php => domain.com/category2/name1/
Details: I have couple of files with the following names & I want them to be shown in the following way.
- category1-name1.php => category1/name1/
- category1-name2.php => category1/name2/
- category1-name3.php => category1/name3/
- category2-name100.php => category2/name100/
- category2-something.php => category2/something/
- category2-lipsum.php => category2/lipsum/
Also, I would like to achieve the following rewrite too
- /category.php => /category/
- /abcd.php => /abcd/
I'm trying but I can't achieve any of it.
I tried this code:
RewriteEngine On RewriteRule ^category1/([^/]+)/?$ category1-$1.php [L] RewriteRule ^category2/([^/]+)/?$ category2-$1.php [L] RewriteRule ^([^/]*)/?$ $1.php [L]
Its only working for /abcd.php to /abcd/ and its throwing 404 errors on rest of the pages, even index is 404 due to it.