typo3: how to solve problems with https_enforcer and htaccess redirect loops

i’ve had some problems getting https_enforcer to work in a typo3 instance with realurl. for some reason i, every attempt at opening a page with the “enforce https” option activated, resulted in a redirect loop error.

how to solve problems with https_enforcer and htaccess forwarding multiple domains to one

as it turns out, one of the issues was an old htaccess redirect rule (not shown here) that was supposed to force visitors from multiple domain names to the main domain name.

here’s the combination of all related the settings that works for me:

typo3 main template: constants
https_enforcer.unsecure_typo3_root = www.domain.com
https_enforcer.secure_typo3_root = www.domain.com

typo3 main template: setup
[globalVar = TSFE:page|tx_httpsenforcer_force_secure = 0]
config.baseURL = http://www.domain.com/
[else]
config.baseURL = https://www.domain.com/
[global]

root htaccess: forward all domain names other than domain.com to www.domain.com
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
 
RewriteCond %{SERVER_NAME} !^www\.domain\.com$ [NC]
RewriteCond %{SERVER_NAME} !^domain\.com$ [NC]
RewriteRule ^(.*)$ %{ENV:ps}://www.domain.com/$1 [L,R=301]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.