Remove File Extention from URLs in .htaccess

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

htaccess-book-02

# Sample 1: 
RewriteRule ^about$ about.php [L]

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s