【问题标题】:TYPO3 breaks urls without WWWTYPO3 在没有 WWW 的情况下破坏 url
【发布时间】:2014-08-13 04:37:41
【问题描述】:

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

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

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

对于“漂亮”的网址,我使用 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

【问题讨论】:

  • 您在这个.htaccess 中还有其他规则吗?
  • 是的,但我觉得没什么特别的。将其添加到我上面的问题中。

标签: apache .htaccess mod-rewrite typo3 realurl


【解决方案1】:

在其他内部重写规则之前保留您的 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]

还要在新浏览器中进行测试以避免浏览器缓存问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-15
    • 2019-02-28
    相关资源
    最近更新 更多