Forum Moderators: coopster

Message Too Old, No Replies

Get current url canonical

         

Pirabdal

5:30 am on Aug 22, 2022 (gmt 0)



Hi

How do we get current url on dynamic page so it can be printed on the http header status


header('Link: <http://example.com/path/to/page.html>; rel="canonical"');

phranque

8:07 am on Aug 22, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], Pirabdal!

i think you are looking for the PHP $_SERVER [php.net] variable.

something like this might work:
$url = "https://" . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];

dstiles

8:12 am on Aug 23, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you just want the page on its own, $_SERVER['SCRIPT_NAME']