I am trying to remove .php from my urls and so I am using this htaccess code:
RewriteEngine on
Options +SymlinksIfOwnerMatch +MultiViews
RewriteBase /
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]
This works fine for urls like this mydomain.com/news
But for urls like this mydomain.com/news/1/news_title it’s being rewritten as mydomain.com/news/1/news_title.php which obviously gives a 404 error. Can anyone help me change the RewriteRule to add .php to just after the first forward slash instead of at the end so that the url is rewritten mydomain.com/news.php/1/news_title?
Many thanks for any help and advice
I hope this will work for you: