RewriteEngine On RewriteCond %{ENV:REDIRECT_OK} !^$ RewriteRule $ - [L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ $1.php [L, E=OK:"1"] RewriteRule ^(.+)\.php$ http://%{HTTP_HOST}/$1 [R=301]