1
votes

How can I configure my TYPO3 website by using the new Site management module to match these tasks:

  1. domain.tld should be the base
  2. www.domain.tld should redirect to domain.tld
  3. SSL should be enforced as well

With earlier versions of TYPO3 i have achieved this by creating two domain records: one for domain.tld and the other for www.domain.tld, defined as permanent redirect to https://domain.tld. SSL was enforced by htaccess:

RewriteCond %{HTTPS}s ^on(s)| [NC]
RewriteRule ^(.*) http%1://domain.tld/? [R=301,L]

In the Site management module of TYPO3 v9 I defined 'https://domain.tld' as Entry point. This works fine so far, but requests for 'www.domain.tld' or 'http://domain.tld' are resulting in a redirect error. I have created the domain records for 'www.domain.tld' and 'domain.tld' as well. Meanwhile I have changed the entry point to '/', at least the requests for 'www.domain.tld' are working now. But what is the best practice to achieve the goals by using the Site management and Redirects modules?

1
Do you need a site configuration for www.domain.ltd or do you just want to redirect www.domain.ltd to domain.ltd?Mikel Wohlschlegel
The latter: a redirect from www.domain.ltd to domain.ltd.Pixelrocker

1 Answers

2
votes

If you just want to redirect all www-traffic to non-www traffic, you can handle that without any TYPO3 configuration. You can redirect all requests from www to non-www with rewrite rules in your webserver configuration directly. In my opinion, there is no need to let TYPO3 handle the redirect at all. It is also faster, as there is no need to "boot" TYPO3 just to handle the redirect.

For apache (example):

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1$1 [R=301,L]

To redirect non https to https:

RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://domain.ltd/$1 [R=301,L]