简体   繁体   English

TYPO3 RealURL重定向循环,用于具有相同标题的链接和页面

[英]TYPO3 RealURL redirect loop for link and page with same title

Most of this seems irrelevant after a number of Debugging. 经过多次调试后,大多数情况似乎无关紧要。 Read EDIT2 for what you need to know. 阅读EDIT2了解您需要了解的内容。

I recently took over development of a TYPO3 webpage and added two new postVars to the realurl_conf.php 我最近接手了TYPO3网页的开发,并在realurl_conf.php中添加了两个新的postVar。

It works as expected on the primary language, but on some pages when viewing it in a different than the primary language I fall into a redirect loop. 它在主要语言上可以正常工作,但是在某些页面上以不同于主要语言查看时,我陷入了重定向循环。

The loop (Temporary Redirect - Code 307) can be reproduced by opening a website, like http://example.com/subpage/?L=2 where 2 is the language ID for English and subpage is the title in English. 可以通过打开网站来复制循环(临时重定向-代码307),例如 http://example.com/subpage/?L=2 ,其中2是英语的语言ID, subpage是英语的标题。 If I open the page via the link http://example.com/unterseite/?L=2 I get the correct page, while unterseite is the title of the page in the primary language. 如果我通过链接 http://example.com/unterseite/?L=2打开页面, unterseite得到正确的页面,而 unterseite是该页面的主要语言标题。

Unfortunately I am unable to see the pattern, as to which pages are affected. 不幸的是,我看不到有关受影响页面的模式。 A total of 3 pages show this misbehaviour, two having child-subpages and the third being a standard page with no children. 共有3个页面显示了此行为,其中两个页面包含子页面,第三页面是没有孩子的标准页面。 The other 11 pages work as expected, with 2 other pages having children. 其他11页按预期工作,另外2页有子级。

All pages are of the standard content type. 所有页面均为标准内容类型。

A failing realurl_conf.php looks like this: 失败的realurl_conf.php如下所示:

 
 
 
 
  
  
  <?php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array ( '_DEFAULT' => array ( 'pagePath' => array ( 'type' => 'user', 'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main', ), ), );
 
 
  

I do not seem to find the issue and I've been googling about it for the last week. 我似乎没有找到问题,上周我一直在搜索它。

Any hint or specific help is very much appreciated. 非常感谢任何提示或特定帮助。

EDIT: removed unneccessary lines. 编辑:删除不必要的行。 The problem occurs reliably with the remaining code With the tx_realurl class (not advanced), the problem does not occur, but the behaviour is not as expected. 使用tx_realurl类(未高级),其余代码可靠地发生了问题,不会发生此问题,但是行为不符合预期。

EDIT2: After a lot of Xdebug debugging, I realized that there is a page with a title say Subpage and there is a secondary menu that contains a link to that page. EDIT2:经过大量Xdebug调试后,我意识到有一个标题为“子页面”的页面,还有一个辅助菜单,其中包含指向该页面的链接。 When opening the URL example.com/subpage/ it detects that subpage is a link to subpage and redirects to subpage. 打开URL example.com/subpage/时,它检测到子页面是子页面的链接,并重定向到子页面。 So what I am looking for is a way to give pages precedence over links, if there is more than one match. 因此,如果有多个匹配项,我正在寻找一种使页面优先于链接的方法。

I guess this is wrong and should be removed: 我猜这是错误的,应该删除:

'valueDefault' => 'de',

The default values for the L-parameter should be set in TypoScript and not in RealUrl. L参数的默认值应在TypoScript中设置,而不应在RealUrl中设置。 And I think that a number value must be entered here, if used. 我认为,如果使用数字值,则必须在此处输入。

TYPO3 has a ".htacess" file shipped under "_.htaccess". TYPO3在“ _.htaccess”下提供了一个“ .htacess”文件。 From TYPO3 6.2.4 I get this: 从TYPO3 6.2.4中我得到:

RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

# Main URL rewriting.
# For httpd.conf, use this line instead of the next one:
# RewriteRule .* /TYPO3root/index.php [L]
RewriteRule .* index.php [L]

Compare your ".htacess" file with the entries from TYPO3's "_.htaccess". 将您的“ .htacess”文件与TYPO3的“ _.htaccess”中的条目进行比较。 Maybe you are missing the L parameter there. 也许您在那里缺少L参数。

You should give a detailed example about the redirections which you have on your website. 您应该提供有关您网站上重定向的详细示例。

I just encountered today the second site having this issue after upgrading TYPO3 and realurl. 今天,在升级TYPO3和realurl之后,我刚刚遇到了第二个遇到此问题的站点。

TL;DR solution: change the 'Speaking URL path segment' of the shortcut to anything different from it's name . TL; DR解决方案: 将快捷方式的“语音URL路径段”更改为不同于name的任何内容

The scenario on my side is: 我这边的情况是:

  • TYPO3 6.2.27 ; TYPO3 6.2.27 ;
  • realurl 2.1.1 / 2.1.4 (these are the two cases encountered until now), but this may happen with all 2.x versions; realurl 2.1.1 / 2.1.4 (这是到目前为止遇到的两种情况),但这可能在所有2.x版本中都发生;
  • page and shortcut with the same name at the same 'path level' ; 页面和快捷方式在相同的“路径级别”上具有相同的名称 remember that this could be the same pagetree level or different pagetree levels, but having parent pages with checked ' Exclude from speaking URL ' checkbox in a manner that bring the two elements at the same 'path level'. 请记住,这可以是相同的页面树级别,也可以是不同的页面树级别,但是要使父页面具有选中的“ 从语音URL排除 ”复选框,以使两个元素处于相同的“路径级别”。

It seems to me that this only appears when realurl 2.x is installed. 在我看来,这仅在安装realurl 2.x时出现。 Both sites had realurl 1.12.x or 1.13.x before the upgrade and there were no issues. 升级之前,两个站点的realurl为1.12.x或1.13.x,并且没有任何问题。

Until the issue is solved at the code level, a possible solution is changing the 'Speaking URL path segment' of the shortcut to anything different from it's name . 在代码级解决问题之前, 可能的解决方案将快捷方式的“ Speaking URL path segment”更改为与name不同的任何内容 The path segment is not used anywhere, but changing it gets you out of this trouble. 路径段没有在任何地方使用,但是更改它会使您摆脱麻烦。

This stopped the redirects on both sites for several page / shortcut pairs on my side. 这在我这边停止了两个站点上几个页面/快捷方式对的重定向。

Another source for a realurl recirect loop: realurl往复循环的另一个来源:

For me it was a broken manual realurl config that had a non-existent rootpage_id set. 对我来说,这是一个损坏的手动realurl配置,其中没有设置rootpage_id Switching to auto-configuration or changing to a correct rootpage_id both fixed the problem. 切换到自动配置或更改为正确的rootpage_id均可解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM