Over a million developers have joined DZone.

Remove File Extention from URLs in .htaccess

DZone's Guide to

Remove File Extention from URLs in .htaccess

Free Resource

This example shows you how to remove file extention from URLs using .htaccess file directives. Remember, that "mod_rewrite" works only on Apache server. Before trying please be sure that you are working on Apache server and the "mod_rewrite" module/extension is enabled.

# Sample 1: 
RewriteRule ^about$ about.php [L]
# Sample 2: 
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}