Runar Posted March 16, 2019 Posted March 16, 2019 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?
AutoItScript Posted March 16, 2019 Posted March 16, 2019 Have you used a relative protocol board path in your conf_global.php file?
Runar Posted March 16, 2019 Author Posted March 16, 2019 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”.
Runar Posted March 18, 2019 Author Posted March 18, 2019 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.
bfarber Posted March 18, 2019 Posted March 18, 2019 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.
Runar Posted March 19, 2019 Author Posted March 19, 2019 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!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.