问题
The problem is that when I want to access my website like www.example.com/my/subpage all works great but when I try to access my website like this (without WWW) example.com/my/subpage TYPO3 breaks it down and redirect it to www.example.com/index.php/subpage.
The redirect from non WWW to WWW is correct but why does it destroy my url? Here is the .htaccess redirect:
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
For the "nice" urls I use the realURL extension. Any ideas?
Edit (more 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:
Keep your 301 rules before other internal rewrite rules:
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]
Also test this in a new browser to avoid browser caching issues.
来源:https://stackoverflow.com/questions/24360834/typo3-breaks-urls-without-www