How to Remove .php from URL in Apache/WordPress

Remove-File-Extension-php-html-from-URL-using-htaccess

How to Remove .php from URL in Apache/WordPress

By default, Apache adds .php to URL for PHP files. Here’s how to remove .php from URL in Apache. You can use these steps to remove .php from URL in WordPress, Magento, Drupal, Joomla and other CMS systems. You can also use it to remove index.php from URLs.

Before proceeding further, you need to enable mod_rewrite in Apache web server. Here are the steps to enable mod_rewrite (.htaccess) in Apache web server.

Remove .php extension from URL

Add the following lines to redirect all URLs with .php extension to URLs without file extension.

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L]