Relative link to a secure version of the website

I have both a secure ( https://111.1.111.111) and insecure ( http://111.1.111.111) website with the same domain. On my insecure home page, I want to put a link to a secure version of the site. I am currently using an absolute link:

<a href="https://111.1.111.111">Please use the secure site</a>

However, I want to change this to a relative link so that if my ip or domain changes, the same code will work. Is there any link to a safe version of my site?

+4
source share
2 answers

You must declare the "base url" as a variable, and then use this variable on your site to create absolute links. For example, if you use php:

<?php
$baseUrl = 'example.com'
?>
<a href="https://<?php echo $baseUrl; ?>">Secure site</a>

$baseUrl , - IP-, .

+1

- , .

Eg.

<a href="/secure?target=payment">Please use the secure site for payments</a>

, .

+1

Source: https://habr.com/ru/post/1607202/


All Articles