Project

General

Profile

Actions

Feature #32343

closed

Default value for url_scheme

Added by Felix Nagel over 12 years ago. Updated almost 7 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2011-12-06
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
medium
Sprint Focus:

Description

Problem:
We want to use https for some pages. Setting url_scheme on these pages together with a TS config like this:

[globalVar = TSFE:page|url_scheme = 2] && [globalString = _SERVER|HTTPS=on]    
    config.baseURL = https://youdomain.com
[global]

works nice so far but the scheme will not change back to http when navigating to non https pages. As we change the baseURL on the calling page, all links to other pages will be linked with https regardless we set these pages to https or not (via url_scheme field).
Changing the baseURL is needed as we want all resources to be https not only the page (html file) itself.

Solution:
We need a default scheme so we could check if its needed to change the scheme for specific links.
Add these lines before checking for url_scheme and forceAbsoluteUrl (about line 5793, file typo3\sysext\cms\tslib\class.tslib_content.php, function typoLink):

$requestUrlScheme = parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
if (!(isset($conf['forceAbsoluteUrl.']['scheme']) && $conf['forceAbsoluteUrl.']['scheme']) && 
        $page['url_scheme'] == 0 && strlen($GLOBALS['TSFE']->config['config']['defaultUrlScheme']) > 0 && $requestUrlScheme != $GLOBALS['TSFE']->config['config']['defaultUrlScheme']) {
    $conf['forceAbsoluteUrl'] = 1;
    $conf['forceAbsoluteUrl.']['scheme'] = $GLOBALS['TSFE']->config['config']['defaultUrlScheme'];
}

Now its possible to use "page.config.defaultUrlScheme = http" to set a default value.
Please note that Ive attached a demo extension (XCLASS) which works pretty nice so far.

Ideas:
It would be awesome to set TS anywhere in the sitetree to force a scheme. This would require the TS config of the linked page which is not available in function typoLink. Im not aware if there is a nice (non performance killing) solution.

Please note: there is a mailinglist thread discussing this issue, search for "Scheme enforcement in 4.5.x" in typo3 dev


Files

T3X_https45-0_0_1.t3x (9.58 KB) T3X_https45-0_0_1.t3x Felix Nagel, 2011-12-06 18:10
T3X_https45-0_0_2.t3x (9.63 KB) T3X_https45-0_0_2.t3x Felix Nagel, 2011-12-08 16:05
T3X_https45-0_0_3-z-201201101755.t3x (9.84 KB) T3X_https45-0_0_3-z-201201101755.t3x Felix Nagel, 2012-01-10 17:55
https46.diff (1.22 KB) https46.diff Alexander Achenbach, 2012-03-28 18:07

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #82797: PageLinkBuilder uses $absoluteUrlScheme outside of forceAbsoluteUrl but the scheme can only be changed when using forceAbsoluteUrlClosedWolfgang Klinger2017-10-18

Actions
Has duplicate TYPO3 Core - Feature #46064: tslib_cObj->typoLink() does not check for a default url_schemeClosed2013-03-06

Actions
Actions #1

Updated by Michael Stucki over 12 years ago

  • Category set to Frontend
  • Status changed from New to Needs Feedback
  • Complexity set to medium

I just replied to your post on typo3-dev:

I've had a look at your approach. I think what you want to do is this:
- Force URLs to be protocol-neutral
- except if the scheme is enforced
- except if the current scheme does not match the new Typoscript setting

However, IMHO this makes little sense practically. You seem willing to define how all URLs (not only some) are requested (HTTP vs. HTTPS), therefore I don't understand why URLs should still be protocol-neutral by default.

So what I suggest is similar to Jigals suggestion:
If a default scheme is defined (using the new Typoscript setting) then we automatically enforce all links to be absolute (similar to forceAbsoluteUrl=1 in Typolink).

That removes some of the magic from your example which I think is not neccessary at all.

Actions #2

Updated by Felix Nagel over 12 years ago

Ive updated the mailinglist:

I've had a look at your approach. I think what you want to do is this:
- Force URLs to be protocol-neutral

What do you mean by protocol-neutral? Relative links?

However, IMHO this makes little sense practically. You seem willing to
define how all URLs (not only some) are requested (HTTP vs. HTTPS),
therefore I don't understand why URLs should still be protocol-neutral
by default.

Im not sure you did understand the problem correctly.

Currently its not possible to have SOME pages with https. Why? Ones a user is using https (forced by url_scheme on a specific page) there is no way to go back to http without > changing the URL manually. Why? Because we need to change the baseUrl of the typoLink calling page to ensure a valid https connection for all resources (not only html but js, > css, pictures, ...).

So IMHO the current implementation of url_scheme is totally useless, as practically you could use https for ALL pages or for NONE (which would be done by baseUrl, no need of > > url_scheme field).
If I am wrong I would love to hear how to use url_scheme in a proper way.

So what I suggest is similar to Jigals suggestion:
If a default scheme is defined (using the new Typoscript setting) then
we automatically enforce all links to be absolute (similar to
forceAbsoluteUrl=1 in Typolink).

Enforcing absoulte urls is what I do in my fix. But not for all links by default, only if needed.

Where should we discuss this? I personally prefer forge as I dont like ml.

Actions #3

Updated by Felix Nagel over 12 years ago

Ive updated my XCLASS to make it usable with BE record preview.

Actions #4

Updated by Felix Nagel over 12 years ago

BE preview fix and extended readme.

Actions #5

Updated by Navi about 12 years ago

It would be awesome to integrate the possibility of a default url_scheme by typoscript in the Core.

Actions #6

Updated by Alexander Achenbach about 12 years ago

I have tested the latest version of the patch (not the extension itself) with TYPO3 4.6.6.
The effective patch extracted from T3X_https45-0_0_3-z-201201101755.t3x still applies
cleanly there.

However (regardless of TYPO3 version 4.5 or 4.6), to my understanding

- the $requestUrlScheme obtained from TYPO3_REQUEST_URL is not really needed, as
setting $page['url_scheme'] based on config.defaultUrlScheme alone and leaving
the rest to existing typolink logic should work well;
- making inequality of $requestUrlScheme and config.defaultUrlScheme a prerequisite for
scheme application causes problems for cross-domain links with $page['url_scheme'] == 0
if at the same time the current request uses HTTPS and 'config.defaultUrlScheme =
https'; in that case, the patch won't provide an explicit scheme as there is no
effective scheme change, which would work for relative URLs (simply keep the current
scheme), but causes an (unexpected) change to the overall typolink scheme default
of 'http' for cross-domain links;
this might also affect forceAbsoluteUrl cases in a similar fashion (not verified).

The attached modified patch (a diff against unmodified TYPO3 4.6.6) tries to address
this by not using any $requestUrlScheme and applying config.defaultUrlScheme directly.

I can submit a patch via Gerrit, just let me know.

Actions #7

Updated by Felix Nagel about 12 years ago

Please note there is a (sleeping) mailing list thread for this issue which includes some important info how to improve url_scheme to make it a usable feature. Search for "Scheme enforcement in 4.5.x" in typo3 dev

@Alexander
Perhaps we should discuss there as it has more information and some more members.
I will try to review your changes asap!

It also has some explanation about a possible TypoScript configuration (which is not possible by the way).

Actions #8

Updated by Charles Coleman over 11 years ago

Felix Nagel wrote:

Please note there is a (sleeping) mailing list thread for this issue which includes some important info how to improve url_scheme to make it a usable feature. Search for "Scheme enforcement in 4.5.x" in typo3 dev

@Alexander
Perhaps we should discuss there as it has more information and some more members.
I will try to review your changes asap!

It also has some explanation about a possible TypoScript configuration (which is not possible by the way).

I have read the thread you referred to and agree that some form of typoscript is needed to override default behavior, etc. When we've got 100,000+ client pages to deal with it's VERY handy to have some typoscript to handle this. Please can this be on the TODO list for TYPO3 6.x?

Actions #9

Updated by Patrick Schriner almost 11 years ago

I like the "light" version of the patch. Is the discussion on this topic still open?

Actions #10

Updated by Alexander Opitz over 10 years ago

Hi Felix,

what is the state of this issue?

Actions #11

Updated by Felix Nagel over 10 years ago

Considered dead. Perhaps you could try to reactive the mailinglist thread but I guess you will need help of a interested core member to achieve anything... sigh

Actions #12

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to New
Actions #13

Updated by Gabe Blair over 10 years ago

We are also interested in making this happen. I'll see if I can get a core update submitted (for TYPO3 6+) via Gerritt, and hopefully we can get this moving forward from there.

PS: typo3.org member can submit a change request using the Gerritt system - have a look at http://wiki.typo3.org/Contribution_Walkthrough_with_CommandLine

Actions #14

Updated by Caspar Stuebs about 10 years ago

Hi,

I do not think this is a Bug.

As I understand the url_scheme field I am able to define if a page should be available through
0 = http and https,
1 = only http,
2 = only https

If you like to define a default scheme you could just change the default value für that field in TCA of table pages in typo3conf/ext_tables.php:

$GLOBALS['TCA']['pages']['columns']['url_scheme']['default'] = '1';

Kind Regards
Caspar

Actions #15

Updated by Sander Leeuwesteijn about 10 years ago

It's not a bug, it's a feature request.

Your suggestion is no solution, you want to be able to configure this per part of page tree / per page. (in the BE instead of in code)

Actions #16

Updated by XIMA MEDIA GmbH almost 10 years ago

Caspar Stuebs wrote:

Hi,

I do not think this is a Bug.

As I understand the url_scheme field I am able to define if a page should be available through
0 = http and https,
1 = only http,
2 = only https

If you like to define a default scheme you could just change the default value für that field in TCA of table pages in typo3conf/ext_tables.php:

$GLOBALS['TCA']['pages']['columns']['url_scheme']['default'] = '1';

Kind Regards
Caspar

There is an error in the TCA syntax:
$GLOBALS['TCA']['pages']['columns']['url_scheme']['config']['default'] = '1';

Actions #17

Updated by Mathias Schreiber over 8 years ago

  • Tracker changed from Bug to Feature

I like the idea, but I need to set this to Feature, though, as this adds a new setting to the core.

Actions #18

Updated by Xavier Perseguers over 8 years ago

I'm not sure this really makes sense anymore. The Internet is moving towards https everywhere and TYPO3 even if it should not enforce that, should embrace it and not look back at what would have been useful 4-5 years ago.

Actions #19

Updated by Benni Mack almost 7 years ago

  • Status changed from New to Rejected

Closing this feature request as we recommend HTTPS everywhere and extensions like "simplessl" for enforcing SSL on all sites plus "config.absRefPrefix = /" solves the base Url problem

Actions #20

Updated by Wolfgang Klinger over 6 years ago

  • Related to Bug #82797: PageLinkBuilder uses $absoluteUrlScheme outside of forceAbsoluteUrl but the scheme can only be changed when using forceAbsoluteUrl added
Actions

Also available in: Atom PDF