Q: Remove all extensions in a .HTACCESS file i would like to remove multiple extensions in an application.
For example in a directory named directory i am having these files


*

*samplehtml.html

*samplephp.php

*sample.pl


I would like to access these files without extensions like


*

*example.com/samplehtml

*example.com/samplephp

*example.com/sample


I found this bit of code, which works for removing a single extension.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.cgi [NC,L]

When i try to add more extensions with this code, only the first one gets working. I have the above one extended as
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.cgi [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]

I hope the last bit which extended has some problems. Can someone help me to resolve.

A: Yes RewriteCond is applicable to very next RewriteRule only. You can have 3 rules as:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ /$1.html [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.cgi -f       
RewriteRule ^(.+?)/?$ /$1.cgi [L]

Alternative: You can avoid all above rules with the following Options:
Options +FollowSymLinks +MultiViews


