Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:05:30+00:00 2026-06-15T11:05:30+00:00

I have a website that can be viewed in both the http and https

  • 0

I have a website that can be viewed in both the http and https protocols, the problem here being that the links and assets must reflect the protocol that the website is being viewed over.

One solution would be to use relative links, however due to particular reasons, I cannot use relative links, resultantly, I have had to find an alternative…

I have recently learned that you can write a link like so in order use the current protocol:

<a href="//www.example.net/test/">Test</a>

Up until now I have been using the following:

<?php

    // Get the current protocol
    $_PROTOCOL = $_SERVER['HTTPS']=='on' ? 'https://' : 'http://';

?>

<a href="<?php echo $_PROTOCOL; ?>www.example.net/test/">Test</a>

Whilst the first solution works, I have only recently discovered it am not familiar with how it works and whether it is reliable. I am aware that older browsers may not like it, but this does not bother me as it is only very old browsers (apparently).

When I tried to generate a sitemap for one of my websites, the urls were written very oddly like so:

http://beta.example.net///venue/

Instead of

http://beta.example.net/venue/

Why is this? Is this because of the links I am using?

Is my original (PHP) solution better, despite the large amount of code to go with it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:05:32+00:00Added an answer on June 15, 2026 at 11:05 am

    You can use “//example.net” anywhere you want to use a regular URL, and it’s a format according to the standard §4.2. RFC 3986.


    However, if you still want to change the scheme of a URL in a clean manner, you can use http_build_url:

    http://php.net/manual/en/function.http-build-url.php

    like this:

    http_build_url("http://yoururl.org", array('scheme'=>'https')); // changes to https://
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my website I have a page that can only be viewed if the
So basically I have website that has names of cities that can be checked
I have a website pune.org that uses places API. As you can see however
I have a button on subject's profile (user that is being viewed), when you
I have been using the 'Web Site Administration Tool' that you can bring up
I have a website that is mainly based on JavaScript. It uses a REST
I have a website that is mirrored cross two sub-domains. So I have separate
I have a website that logs in using an STS, then gets a delegated
I have a website that in a few months is going to have traffic
I have a website that includes a few loading Gifs that spin while certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.