为 TYPO3 后端强制 www

Force www for TYPO3 backend

TYPO3 6.2 站点的 .htaccess 有这两个 URL 重写块(以及其他)

# Regular TYPO3 / RealURL rewrites
RewriteEngine On
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

# force www for frontend to avoid duplicate content
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/ [L,R=301]

如何为后端 (/typo3/typo3/typo3/index.php) 也强制使用 www?

我试过 RewriteRule ^typo3(.*)?$ http://www.%{HTTP_HOST}/typo3/ [R=301,L] 之类的东西,但只遇到错误。

所以也许我什至不需要强制使用 www,但要澄清为什么重写不会在它应该停止的地方停止。

不确定是否相关:https://forge.typo3.org/issues/65705

像这样重新排列您的规则:

# Regular TYPO3 / RealURL rewrites
RewriteEngine On

# force www for frontend to avoid duplicate content
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteRule ^typo3(/.*)?$ - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]