Jump to content

Is there a way to prevent duplicate content issue with Google by removing index.php from URLs when Full Friendly URLs are enabled?


Cool Deed

Recommended Posts

Hi All,

I hope everyone is well. So I enabled Full Friendly URLs, but Google reports many duplicate content in Search Console.
For eg. https://mydomain.com and https://mydomain.com/index.php have the same content.
https://mydomain.com/login and https://mydomain.com/index.php/login and many others.

My question is,
Is there a way to prevent the duplicate content issue with Google by removing index.php from URLs when Full Friendly URLs are enabled?

I must note that I have a hook file that helps make links canonical and is pasted below:

<?php
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

add_hook('ClientAreaHeadOutput', 1, function($vars)
{

        $SystemURL = 'https://mydomain.com';
        $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        $url = strtok($url, '?');
    return <<<HTML
    <link rel="canonical" href="{$url}"/>
HTML;
});
Thank you.

Kind regards.
Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated