Have you ever noticed a trend that many top ranking websites on search engines showing links that lack the .aspx, .html and .php extension. Many top SEO marketing companies use this practice. URL rewriting doesn’t actually remove the extension but instead hides it. So, today you will get to know how to remove file extension from URL.

Benefits of using an extension less URL.

  • URLs look cleaner.
  • They are easy to type.
  • It’s easy to remember.
  • Make URLs more SEO keyword friendly.
  • You can change technologies.
  • Can hide technologies behind it.

There is no direct SEO benefit of removing file extension but yet you get a better looking clean URLs with few characters which is good for user experience. Another benefit of removing file extension is, you can change your back-end technology without migrating all URLs by editing all your pages.

Another advantage of removing file extension in the URL is that those URLs are easier to read by humans and look user friendly in the search results. It also helps in security point of view as it hides back-end technology. It is still negligible as it’s not hard to identify the technology.


let us assume that you have “mod_rewrite” PHP extension already installed and enabled.

Remove File Extension from URL (AKA “Clean URLs”)

Below is the example on how to remove .php from URL.

Use this:

Without File Extension

Instead of this:

With File Extension

For example, if you need to change www.yoursite.com/services.php to www.yoursite.com/services add the following lines in .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]

Redirect URL from with File Extension to without File Extension

Using above rules visitor who type URL with www.yoursite.com/services.php will not redirect. Now, after removal of file extension from URL, we also need visitors to redirect from with file extension to without file extension. For example, if a user types URL with extension like www.yoursite.com/services.php then they should redirect to www.yoursite.com/services. To achieve that add the following lines to your .htaccess file.

RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

The above examples are for .php file extension. If you want to remove other extensions like .html, .aspx etc., just change .php to any extension to serve the same purpose.