Forum Moderators: phranque
RewriteRule ^(.*)\.([^/]+)$ /$1 [R=301,L]
RewriteRule ^(([^/]*/)*[^/.]+)+\.[^/.]+$ http://www.example.com/$1 [R=301,L]
RewriteRule ^sitemain/style\.css$ - [L] If extensionless URL-path requested {
If requested URL-path plus .php exists as a file {
rewrite to .php file
}
Else if requested URL-path plus .html exists as a file {
rewrite to .html file
}
Else if requested URL-path plus .shtm exists as a file {
rewrite to .shtm file
}
Else if requested URL-path plus .xhtm exists as a file {
rewrite to .xhtm file
}
Else if requested URL-path plus .asp exists as a file {
rewrite to .asp file
}
Else return 404-Not Found
}
if (extension exists in request) {
if not (.gif, .png, .jpg, .css, .js, .txt, .ico, .xml) {
301 extension => non extension
}
}
# Externally redirect only direct client requests for "page" URL-paths
# with appended file extensions to corresponding extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/?\ ]*/)*[^/.?\ ]+\.(php|s?html)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*[^/.]+)\.(php|s?html)$ http://www.example.com/$1 [R=301,L]
#
#
# The following three rules invoke OS calls to check the filesystem which may invoke
# physical disk accesses. These checks are very resource-intensive. Therefore, do not
# add additional filetypes without considering this performance impact.
#
# Internally rewrite extensionless request to .php file (if it exists)
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(([^/]*/)*[^/.]+)$ /$1.php [L]
#
# Internally rewrite extensionless request to .html file (if it exists)
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(([^/]*/)*[^/.]+)$ /$1.html [L]
#
# Internally rewrite extensionless request to .shtml file (if it exists)
RewriteCond %{REQUEST_FILENAME}.shtml -f
RewriteRule ^(([^/]*/)*[^/.]+)$ /$1.shtml [L]
#
[edited by: jdMorgan at 6:49 pm (utc) on Feb 25, 2010]
RewriteCond $1 !\.[^/.]+$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(([^/]*/)*[^/.]+)$ /$1.php [L] [edited by: jdMorgan at 6:51 pm (utc) on Feb 25, 2010]
[edit reason] Corrected copied rule as noted below. [/edit]