Last active
September 7, 2019 03:08
-
-
Save ludndev/57e3e479f97b9269fb5b20801800e9ff to your computer and use it in GitHub Desktop.
Generate canonical url with PhP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get the rigth protocol | |
$protocol = !empty($_SERVER['HTTPS']) ? 'https' : 'http'; | |
// simply render canonical base on the current http host ( multiple host ) + requests | |
echo $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment