TYPO3 breaks urls without WWW

末鹿安然 提交于 2020-02-25 05:58:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!