How to create htaccess seo friendly url rewriterules for e.g a/b/c

Viewed 149

I'm searching from last few days and here in stackoverflow, there are lots of questions but unfortunately, none is working for me, that's why I'm asking according to my problem

I have to create a beautiful SEO friendly urls using htaccess. Some of the tasks have been completed but one link still needs to be SEO friendly. e.g example.com/pages/my-page/my-page-first-post

details:
example.com is my site
pages is rewritten rules page.php
my-page is SEO friendly title of the page

Now what I need is
my-page-first-post so the url must be example.com/pages/my-page/my-page-first-post
It is fine till example.com/page/my-page/

working htaccess code RewriteRule ^pages/([A-Za-z0-9-]+)/?$ page.php?pages=$1 [QSA,L] and I'm trying for adding pages posts titles. RewriteRule ^([A-Za-z0-9-]+)/?$ page.php?pages=$1/page.php?title=$2 [QSA,L]

Thanks for helping in this case

1 Answers

These 2 rules should be able to handle your pretty URL schemes:

RewriteRule ^pages/([\w-]+)/?$ page.php?pages=$1 [QSA,NC,L]

RewriteRule ^pages/([\w-]+)/([\w-]+)/?$ page.php?pages=$1&title=$2 [QSA,NC,L]
Related