TYPO3会在没有WWW的情况下中断URL

TYPO3会在没有WWW的情况下中断URL

本文介绍了TYPO3会在没有WWW的情况下中断URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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]

对于不错"的网址,我使用realURL扩展名.有什么想法吗?

For the "nice" urls I use the realURL extension. Any ideas?

编辑(更多htaccess):

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

推荐答案

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

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.

这篇关于TYPO3会在没有WWW的情况下中断URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 13:54