Jump to content

Force URLs to be written with full protocol (https)


Runar

Recommended Posts

Posted

It seems all URLs are written with relative protocol (like this: //example.com/loremipsum), and I believe this is messing with my attempts to use PageSpeed.

Is there any easy way to force all URLs, including those in posts and other content, to be written with the full protocol?

Posted
12 minutes ago, AutoItScript said:

Have you used a relative protocol board path in your conf_global.php file?

No, my board url is set to “https://www.example.com”.

Posted

Apparently this is expected behavior when using a CDN (when a custom domain/path is set in the storage configuration it counts as using a CDN), according to support. They claim it's not possible to force all URLs to include the protocol.

I understand it's not possible to do by clicking a button, but it must be possible by editing the core files (stupid idea, I know). I am willing to take this risk, however, as I need to debug why PageSpeed is behaving strange. Does anyone have any idea where I need to start? I've tried to edit both the Url and File classes (I'll post the exact code later) without it making any difference.

Posted

If you were going to edit source files to do this for debugging purposes, you'd need to edit the Url class as that's where the URLs are generated from. I don't have exact edits for you, but you'd want to force the protocol to something other than PROTOCOL_RELATIVE (probably PROTOCOL_HTTPS) in the various functions that generate a URL.

Posted

Thank you for your reply, @bfarber! Replacing «//» with «https://» on the following two lines seemed to do the trick:

system/File/Amazon.php, line 241:

return preg_replace( '#^http(s)?://#', 'https://', rtrim( ( empty( $this->configuration['custom_url'] ) ) ? static::buildBaseUrl( $this->configuration ) : $this->configuration['custom_url'], '/' ) );

system/Http/Url.php, line 833:

$url = 'https://' . mb_substr( $url, mb_strpos( $url, '://' ) + 3 );

However, it seems there are other causes for my PageSpeed issues, so I’ll most likely revert back to the original lines after I’m done investigating. It was very helpful, though, to be able to force the full protocol in all links and URLs!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...