[BUGFIX] TypoLink: absolute urls when installed in subfolder
authorNils Seinschedt <n.seinschedt@neusta.de>
Mon, 16 Jan 2012 09:59:46 +0000 (10:59 +0100)
committerXavier Perseguers <xavier@typo3.org>
Tue, 6 Mar 2012 08:49:32 +0000 (09:49 +0100)
If you have TYPO3 installed in a subfolder and a domain
record with that subfolder (localhost/subfolder/ for
example) TYPO3 only generates absolute links in the
frontend.

This is because the typoLink function compares the
HTTP_HOST var with the domainRecord. HTTP_HOST is in
this case "localhost", the domain record has the subfolder
attached. The subfolder needs to be there, as otherwise
t3lib_pageSelect::getDomainStartPage does not find the
start page anymore. typoLink should check for HTTP_HOST +
path of SCRIPT_NAME to determine which domain record
to use (same as getDomainStartPage already does).

Change-Id: I50fc642ca4fb4c4522e0fc1e2dc4a4c391f54e4f
Fixes: #33214
Releases: 4.5,4.6,4.7
Reviewed-on: http://review.typo3.org/9074
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/cms/tslib/class.tslib_content.php

index ec466c3..c3e3f6a 100644 (file)
@@ -5756,7 +5756,16 @@ class tslib_cObj {
                                                        $GLOBALS['TYPO3_DB']->sql_free_result($res);
 
                                                                // Set targetDomain to first found domain record if the target page cannot be reached within the current domain
-                                                       if (count($foundDomains) > 0 && (!in_array($currentDomain, $foundDomains) || count($firstFoundForcedDomains) > 0)) {
+                                                       if(
+                                                               count($foundDomains) > 0 &&
+                                                               (
+                                                                       (
+                                                                               !in_array($currentDomain, $foundDomains) &&
+                                                                               !in_array($currentDomain . trim(preg_replace('/\/[^\/]*$/', '', t3lib_div::getIndpEnv('SCRIPT_NAME'))), $foundDomains)
+                                                                       ) ||
+                                                                       count($firstFoundForcedDomains) > 0
+                                                               )
+                                                       ) {
                                                                foreach ($targetPageRootlinePids as $pid) {
                                                                                // Always use the 'forced' domain if we found one
                                                                        if (isset($firstFoundForcedDomains[$pid])) {