How to add ".php" extension using ".htaccess" file How to add ".php" extension using ".htaccess" file apache apache

How to add ".php" extension using ".htaccess" file


Considering that you want to check if filename(from uri).php is present on local filesystem then you need to redirect request to that specific file without rewriting url in browser, if this is the case please try following.

RewriteEngine ONRewriteCond %{REQUEST_FILENAME}.php -fRewriteRule ^(.*)$ $1.php?id=%{QUERY_STRING} [END]

NOTE: In above rules change from END to L in case you have further more rules.