TYPO3-metaseo icon indicating copy to clipboard operation
TYPO3-metaseo copied to clipboard

If custom subdirectory is configured with config.absRefPrefix, fullUrl returns wrong absolute uri

Open thomaszbz opened this issue 8 years ago • 12 comments

If config.absRefPrefix is used, fullUrl returns wrong absolute uri

Reported by @Teddytrombone via PR #353 :

Example: config.absRefPrefix = /test/ results in http://example.com/test/test/page/ instead of http://example.com/test/page

PR #353 should work with sites which use config.absRefPrefix as well as config.baseUrl

MetaSEO version: 2.0.3

TYPO3 version: 7.6.15

@Teddytrombone Thanks for catching and patching this. I have some questions:

  • Which versions are you using?
  • Which is the URL of your root page (e.g. http://www.example.com/test/)?

thomaszbz avatar Feb 22 '17 08:02 thomaszbz

If this can be classified as a bug, then it's (very likely) a regression via d8b91f66d13b6824aff8b6cad6e14c91765087c2 which went productive via 1.0.6. Affected versions are 1.0.6 - 2.0.3, respectively (issue #355).

When reviewing the fix provided by @Teddytrombone, we need to make sure to not introduce the // problem again (issue #355). Eventually, add this to the test suite.

thomaszbz avatar Feb 22 '17 09:02 thomaszbz

Which versions are you using?

We are using the current version from TER (2.0.3)

Which is the URL of your root page

I don't know, if get the question right. Do you mean the TYPO3 frontend? On our development server, we have TYPO3 installations in subdirectories, but needed the config.absRefPrefix (to get over some inline svg limitations in Firefox). So our configuration is: config.absRefPrefix = /subdirectory/ The TYPO3 frontend is accessible via http://internal.domain/subdirectory/ and the backend via http://internal.domain/subdirectory/typo3/

With the above configuration, all internal links are absolute links (of course), but for example for the canonical url the subdirectory is duplicated, for example the root page: http://internal.domain/subdirectory/subdirectory/

Or a subpage http://internal.domain/subdirectory/de/some/test/page/ gets the canonical url http://internal.domain/subdirectory/subdirectory/de/some/test/page/

The cause is, that in GeneralUtility::fullUrl always TYPO3_SITE_URL is prepended, which returns the domain and the subdirectory. So for absolute links, only the domain should be prepended.

I hope, this clarifies things ;-)

Teddytrombone avatar Feb 24 '17 17:02 Teddytrombone

The TYPO3 frontend is accessible via http://internal.domain/subdirectory/

That answers it.

Which TYPO3 version are you using?

thomaszbz avatar Feb 24 '17 20:02 thomaszbz

Which TYPO3 version are you using?

TYPO3 7.6.15

Teddytrombone avatar Feb 26 '17 10:02 Teddytrombone

With minimal configuration:

config.tx_realurl_enable = 1
config.absRefPrefix = /customdir/

Reproduced for sitemap index:

auswahl_168

However, URLs in a sitemap page are correct:

auswahl_169

Part of the problem is that we call fullUrl() with both, absRefPrefixed and unprefixed paths.

thomaszbz avatar Apr 06 '17 20:04 thomaszbz

@Teddytrombone @MichiBeck, @pdanzinger, @bla-kw, @fdrewes Could you please test/review patch 70d84d6c028d10b1f9c3f9a3754517f2484feb70 against your test environments?

I don't want to introduce another regression here. It's a #357-similar issue, just with absRefPrefix = /customdir/, meaning that TYPO3 is installed in a subdirectory.

For your root page, eventually you have to work around a RealUrl issue. See #370.

thomaszbz avatar Apr 07 '17 13:04 thomaszbz

Sorry, I'm on vacation at the moment. I will test this after the easter holidays.

Teddytrombone avatar Apr 07 '17 15:04 Teddytrombone

Sorry, but the patch doesn't work for me. The generated canonical url still contains the subdirectory twice. In GeneralUtility::fullUrl the $domain parameter is NULL, so the full TYPO3_SITE_URL is added in front of the url, which contains the subdirectory allready.

Teddytrombone avatar Apr 26 '17 09:04 Teddytrombone

@Teddytrombone Thanks for reporting back.

For the root page, I can say that there's a bug in RealUrl.

Please try:

  • go back to metaseo 2.0.4 production release
  • Apply the workaround (SQL) from https://github.com/mblaschke/TYPO3-metaseo/issues/370
  • Clear all caches
  • Delete wrong entries in the sitemap
  • See what happens. Maybe try again with 70d84d6 and the SQL workaround applied.

thomaszbz avatar Apr 26 '17 09:04 thomaszbz

I did my tests on subpages, and it didn't work either.

I don't think it's a bug in RealUrl, because if i disable RealUrl, the problem still exists.

config.tx_realurl_enable = 0
config.absRefPrefix = /customdir/

bildschirmfoto von 2017-04-27 10-11-20

Teddytrombone avatar Apr 27 '17 08:04 Teddytrombone

Has this bug still not been removed? I have this problem with current version 3.0.0

geri777 avatar Apr 07 '18 17:04 geri777

The bug only occurs when setting absRefPrefix without protocol+host.

Setting page.config.absRefPrefix = https://domain.com/subfolder/ instead of page.config.absRefPrefix = /subfolder/ fixed it for me.

arnekolja avatar Oct 08 '18 09:10 arnekolja