I want to make seo friendly url using .htaccess.
I want to convert below url
http://localhost/projectname/pagename.php?id=1
to
http://localhost/projectname/pagename/1
I have already tried solution for this
RewriteRule ^pagename/([a-zA-Z0-9]+)/$ projectname/pagename.php?id=$1
But it's not working
I have also referred below links but not giving me right solution
How to write htaccess rewrite rule for seo friendly url
Creating SEO friendly urls using htaccess
.htaccess file
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^pagename/([a-zA-Z0-9]+)/$ projectname/pagename.php?id=$1
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
using above htaccess file I can remove .php
extention from url but not to generate seo friendly url.
Thank you a lot in advance.