Skip to content

Instantly share code, notes, and snippets.

@nshCore
Created December 20, 2016 09:01
Show Gist options
  • Save nshCore/47c65f6622a49eebc5d502991de62291 to your computer and use it in GitHub Desktop.
Save nshCore/47c65f6622a49eebc5d502991de62291 to your computer and use it in GitHub Desktop.
.htaccess to remove .html and .php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
@nshCore
Copy link
Author

nshCore commented Dec 20, 2016

If you use godaddy you shouldn't but you might need to enable multiviews by adding this at the top

Options +MultiViews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment