Categories
Web Development

Removing .htm .html extentions and trailing slashes from your urls

Quick post I just wanted to share this with you if you ever need to remove trailing slashes or .html extentions from your uls.
This works with wordpress.

Line 4 removes the trailing .html
Line 5 removes the trailing .htm
Line 6 removes the trailing slash

Feel free to copy and paste into your own .htaccess file.
** Note: change domain.com to your own domain name

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)\.html(.*) http://domain\.com/$1 [L,R=301]
RewriteRule ^(.*)\.htm(.*) http://domain\.com/$1 [L,R=301]
RewriteRule (.+)/$ $1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress