Blog Details

Removing file extension via .htaccess



                                

Problem: You have the following URLs for your website: www.wamasoftware.com/about-us.html www.wamasoftware.com/services.html www.wamasoftware.com/contact-us.html However, you would like to hide file extensions from the end users, and allow them to access to the files using the following URLs: www.wamasoftware.com/about-us www.wamasoftware.com/services www.wamasoftware.com/contact-us Solution: The solution can be achieved by using Apache’s mod_rewrite. Create an .htaccess file in your website root directory with the following content. RewriteEngine On RewriteCond %{REQUEST_FILENAME}!-d RewriteCond %{REQUEST_FILENAME}!-f RewriteRule ^([^.]+)\.html$ $1 [L] # Replace html with your file extension, eg: php, htm, asp Correction

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
# Replace html with your file extension, eg: php, htm, asp


Categories

Technology

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote