Remove .php extention from url working but seo friendly url not working
<p>I want to make seo friendly url using .htaccess.</p>

<p>I want to convert below url</p>

<pre><code>http://localhost/projectname/pagename.php?id=1
</code></pre>

<p>to</p>

<pre><code>http://localhost/projectname/pagename/1
</code></pre>

<p>I have already tried solution for this</p>

<pre><code>RewriteRule ^pagename/([a-zA-Z0-9]+)/$ projectname/pagename.php?id=$1
</code></pre>

<p>But it's not working </p>

<p>I have also referred below links but not giving me right solution</p>

<p><a href="https://stackoverflow.com/questions/28168375/how-to-write-htaccess-rewrite-rule-for-seo-friendly-url">How to write htaccess rewrite rule for seo friendly url</a></p>

<p><a href="https://stackoverflow.com/questions/26285463/creating-seo-friendly-urls-using-htaccess">Creating SEO friendly urls using htaccess</a></p>

<p>.htaccess file</p>

<pre><code>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]
</code></pre>

<p>using above htaccess file I can remove <code>.php</code> extention from url but not to generate seo friendly url.</p>

<p>Thank you a lot in advance.</p>