Forum Moderators: phranque
Duplicate, submitted URL not selected as canonical
Status:
Excluded https://www.example.com/mysubdirectory/index.php https://www.example.com and this is my main script. https://www.example.com/mysubdirectory/index.php I have installed another script. https://www.example.com with all the pages but on the other hand, google having some issue indexing some of my second scripts URLs https://www.example.com/mysubdirectory/index.php (This is perfectly indexed by google) https://www.mylinkconverter.com/mysubdirectory/how-to-1
https://www.mylinkconverter.com/mysubdirectory/how-to-2
https://www.mylinkconverter.com/mysubdirectory/how-to-3
https://www.mylinkconverter.com/mysubdirectory/how-to-4
<link rel="canonical"
href="<?php echo $canonical_url ?>"/> <?php
require_once __DIR__ . "/system/config.php";
$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$parse_main_url = parse_url($config["url"]);
$parse_current_url = parse_url($current_url);
$canonical_url = $current_url;
$slug = substr(str_replace($parse_main_url["path"], "", $parse_current_url["path"]), 1);
$content["content_type"] = -1;
preg_match('/watch\?v=(.*)/', $_SERVER["REQUEST_URI"], $watchSlug);
if (isset($_GET["lang"]) != "") {
if (language_exists(clear_string($_GET["lang"])) === true) {
$_SESSION["current_language"] = clear_string($_GET["lang"]);
require_once(__DIR__ . "/language/" . $_SESSION["current_language"] . ".php");
}else if (isset($_SERVER["HTTP_REFERER"]) != "") {
redirect($_SERVER["HTTP_REFERER"] . "?lang=" . $_GET["lang"]);
} else {
redirect($config["url"]);
}
} else {
$canonical_url .= "?lang=" . $_SESSION["current_language"];
}
https://www.mylinkconverter.com/mysubdirectory/how-to-1
https://www.mylinkconverter.com/mysubdirectory/how-to-2
https://www.mylinkconverter.com/mysubdirectory/how-to-3
https://www.mylinkconverter.com/mysubdirectory/how-to-4
how can I fix this canonical issue?
$canonical_url = $current_url