PDA

View Full Version : how to remove .php extension from url



kpw81
11-26-2008, 11:57 AM
i am trying to change the style of url i have for a dynamic website, whereby instead of having a url such as articles.php?id=1234, i have one which looks like articles/category/title-of-article. i have used the following code in my .htaccess file to allow me to view the url without the .php file extension, but it goes wrong when i add a /category/title-of-article.


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php


if i go to the url with the .php extension followed by /category/title-of-article, it works fine but it doesn't look very good having the extension in the middle of the url.

is there a way to remove the php extension from the middle of the url, or to add extra characters at the end of the url after where the .php has been removed without creating an internal server error?