TYPO3在没有WWW的情况下打破网址

时间:2014-06-23 07:47:27

标签: apache .htaccess mod-rewrite typo3 realurl

问题在于,当我想访问我的网站时,例如 www.example.com/my/subpage 一切都很好但是当我尝试访问我的网站时(没有WWW) example.com/my/subpage TYPO3将其分解并将其重定向到 www.example.com/index.php/subpage

从非WWW到WWW的重定向是正确的,但为什么它会破坏我的网址?这是.htaccess重定向:

RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

对于" nice" urls我使用realURL扩展。有什么想法吗?

编辑(更多htaccess):

RewriteRule ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/ - [L]
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

1 个答案:

答案 0 :(得分:2)

在其他内部重写规则之前保留301规则:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^ http://www.example.com%{REQUEST_URI} [L,R=301,NE]

RewriteRule ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/ - [L]
RewriteRule ^typo3(/.*)?$ - [L]

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

还要在新的浏览器中测试它,以避免浏览器缓存问题。

相关问题