Skip to content

Instantly share code, notes, and snippets.

View fseonline's full-sized avatar

FSE Online fseonline

View GitHub Profile
@fseonline
fseonline / header.php
Created April 26, 2019 10:35
Apply Canonical tag to basic PHP sites
<?php
/**
* Apply correct canonical tag for Forest Drive and Resin
* @author Freelance SEO Essex
* @link https://www.freelanceseoessex.co.uk/
*/
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$dirname = pathinfo($actual_link)['dirname'];
if( $dirname === 'http:' ) {