SEO - Semrush - 1 Incorrect Page Found In Sitemap.xml - Non-canonical URL
I am having an issue with my home page or index.php page, When I set canonical to
<link rel="canonical" href="https://example.com/" />
I get the SEO error for https://example.com/home
If I set canonical to
<link rel="canonical" href="https://example.com/home" />
I get the SEO error for https://example.com/
With PHP I have tried the following:
<?php $currentPage = str_replace("/", "", $_SERVER['REQUEST_URI']); ?> <link rel="canonical" href="https://example.com/<?php echo $currentPage; ?>" />
What am I doing wrong here?
When you have two URLs pointing to the same content, you need to mark one of them as canonical.
/home give you the same page, then both pages should say:
<link rel="canonical" href="https://example.com/">
Just to be clear: both should say that. Neither should say:
<link rel="canonical" href="https://example.com/home"><!-- this is wrong -->
In addition only the canonical page should appear in sitemap.xml.
/home should not appear in sitemap.xml. (It doesn't make sense to say "Please index
/home" in the sitemap only to immediately say "Don't index
/ instead" in the page itself)
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?