I have a website that can be viewed in both http and https protocols, the problem is that the links and assets should reflect the protocol being viewed by the website.
One solution would be to use relative links, however for some reason I cannot use relative links, as a result I had to find an alternative ...
I recently found out that you can write such a link to use the current protocol:
<a href="//www.example.net/test/">Test</a>
So far I have used the following:
<?php // Get the current protocol $_PROTOCOL = $_SERVER['HTTPS']=='on' ? 'https://' : 'http://'; ?> <a href="<?php echo $_PROTOCOL; ?>www.example.net/test/">Test</a>
While the first solution is working, I only recently discovered that he is not familiar with how it works and whether it is reliable. I know that older browsers may not like this, but this does not bother me, since these are only very old browsers (apparently).
When I tried to create a sitemap for one of my sites, the URLs were written very strange:
http://beta.example.net///venue/
Instead
http://beta.example.net/venue/
Why is this? Is it because of the links I use?
Is my original (PHP) solution better despite the large amount of code to go with it?
source share