skip to Main Content

Using PHP for canonical urls – SEO

I set the following rule in my .htaccess file to redirect example.com/index.php to example.com RewriteCond %{THE_REQUEST} ^.*/index.php RewriteRule ^(.*)index.php$ /$1 [R=301,L] Then I set my canonical as following in the header.php for all pages: <link rel="canonical" href="https://www.example.com<?php echo $_SERVER['PHP_SELF']; ?>"…

VIEW QUESTION
Back To Top
Search