When you install WordPress in a sub directory Example: ‘blog’, the canonical link should be: www.example.com/blog/. But Canonical url trailing slash will be missing for homepage. Yoast will show the home page canonical tag, without having a trailing slash like this : www.example.com/blog
All pages will show the canonical URLs as having a trailing slash except the home page. Yoast WordPress SEO plugin gives canonical url and sitemap url as www.example.com/blog which is incorrect. So the problem is, Google will index home page (www.example.com/blog/) without a trailing slash. The SEO plugin should put the trailing slash in the canonical url and in the sitemap when the site is in a subdirectory.
There is no need for editing .htaccess file. You can fix this issiue from WordPress admin panel.
Wordpress admin panel -> Plugins -> Editor. Select WordPress SEO from the right top of the page. Find and select the file “wordpress-seo/frontend/class-frontend.php” from the right side of files list.
In that file, find this code: ” $canonical = home_url(); ”
Update that code like this : ” $canonical = home_url(‘/’); ”
Canonical url trailing slash will be showing for home page (www.example.com/blog/)
Latest posts by Sanju (see all)
- How to start Angularjs 4 with Angular CLI - August 15, 2017
- The Ruins of Belapur Fort - October 24, 2016
- How to redirect url with or without www in htaccess - April 30, 2016