Created
November 1, 2017 12:59
-
-
Save lomboboo/396aa42762cd1f5f388457d6730d9186 to your computer and use it in GitHub Desktop.
htaccess file - dynamic (subdirectories) removing html extension, redirecting filename.html to filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteBase / | |
# %{ENV:BASE} is now subdirectory, ex. /folder/subfolder/ | |
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ | |
RewriteRule ^(.*)$ - [E=BASE:%1] | |
RewriteCond %{REQUEST_METHOD} !POST | |
RewriteCond %{THE_REQUEST} /(.+?)\.html[\s?] [NC] | |
RewriteRule ^ %1 [R=302,L,NE] | |
# rewrite index to / | |
RewriteRule ^(.*)index$ %{ENV:BASE} [R=301,NC,L] | |
# To internally forward /dir/file to /dir/file.html | |
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.html -f [NC] | |
RewriteRule ^(.+?)/?$ %{ENV:BASE}$1.html [L] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment