简体   繁体   中英

TYPO3 9: Domain routing and redirects with site management

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?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM