-2

Have seen lots of individual threads on how to generate a fully qualified website URL, e.g.

https://www.example.com/

The majority of the threads are a few years old and have mentions of security risks with using the code.

Is there a more up to date and secure way of retrieving the qualified URL in PHP?

UPDATE:

I wish to keep a global string, auto-generated, of the top level website address to use in the pages on the website.

Barton
  • 143
  • 2
  • 2
  • 10
  • 1
    For reference : https://stackoverflow.com/questions/28314414/how-to-get-fully-qualified-url-from-anchor-href – Virb Jul 26 '17 at 08:34
  • Could you give us a bit more insight into what you are trying to achieve, and also link to the threads that you mentioned? – Matt Rink Jul 26 '17 at 08:34
  • 1
    Please give us what you wish to achieve and what kind of input you're expecting. Are you trying to rebuild the url of the current viewed page? or is it user input? what do you intend to do with it? – Tschallacka Jul 26 '17 at 08:35
  • Possible duplicate of [How to get fully-qualified URL from anchor href?](https://stackoverflow.com/questions/28314414/how-to-get-fully-qualified-url-from-anchor-href) – Masivuye Cokile Jul 26 '17 at 08:37
  • @Virb you have mentioned the prime link on the subject, and how many responses and solutions are there, highly confusing and no hard or fast solution recognised. Clarification would be great. – Barton Jul 26 '17 at 09:18

1 Answers1

0
$actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

refer : Get the full URL in PHP

Arun pandian M
  • 862
  • 10
  • 17