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...
  • 2 months later...
On 8/2/2023 at 9:16 AM, Cool Deed said:

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.

Any news on this matter?

I have duplicate urls on a multilanguage site.

Whmcs still does not officially provide a solution to this issue (I have consulted with them).

Has anyone had luck with this?

Link to comment
Share on other sites

  • 2 weeks later...

Removing index.php should definitely fix the duplicates.  Your hook looks like a good start, but have you tried checking the WHMCS documentation for their official method on enabling clean URLs?  They might have a built-in solution.

Link to comment
Share on other sites

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