Forum Moderators: phranque
# Internal rewrite for extensionless url
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.html [L]
#External redirect for extensionless url
RewriteCond %{THE_REQUEST} https://example.com\.html
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
I just needed to replace the above line with this
#External redirect for extensionless url
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.+)\.html$ https://example.com/$1 [R=301,L]
Options +Includes
Options +FollowSymLinks
RewriteEngine on
# External redirect for extensionless url
RewriteRule ^(.+)\.html$ https://example.com/$1 [R=301,L]
# redirect for NON-www and/or force HTTPS
RewriteCond %{HTTP_HOST} !(example\.com)?$ [NC,OR]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# Internal rewrite for extensionless url
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.html [L]
No, in this situation a RewriteCond looking at THE_REQUEST is essential, because otherwise you get an infinite loop...
Options +Includes
Options +FollowSymLinks
RewriteEngine on
# External redirect for extensionless url
RewriteCond %{THE_REQUEST} \.html$
RewriteRule ^(.+)\.html$ https://example.com/$1 [R=301,L]
# redirect for NON-www and/or force HTTPS
RewriteCond %{HTTP_HOST} !(example\.com)?$ [NC,OR]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# Internal rewrite for extensionless url
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.html [L]