Return to Snippet

Revision: 70303
at January 9, 2016 03:44 by jefferis


Initial Code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteRule ^([^\.]+)$ $1.htm [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Initial URL
http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/

Initial Description
Removing extensions and trailing slashes  in web urls:
"If you want to remove the .html extension from a html file for example yoursite.com/wallpaper.html to yoursite.com/wallpaper you simply have to alter the last line from the code above to match the filename"
Not sure if the middle 2 lines are needed.

Initial Title
Removing extensions and trailing slashes  in web urls:

Initial Tags
php, html

Initial Language
Apache