/ Published in: Apache
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.
"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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]
URL: http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/