PHP two line codes add Canonical tag in website every page
Add canonical tag dynamically by using PHP code easily with two lines of code. Canonical tag using on a webpage that tells search engines that specific URL represents the master copy not having any duplicate page. Using canonical tag shows duplicate content present on different or multiple URLs.
<?php $actual_link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; ?> <link rel="canonical" href="<?php echo dirname($actual_link).'/'; ?>" />
Live in Delhi, Working in Gurgaon as Web Designer and Graphic Designer. Developed and Design myfreeonlinetools for online free tools. Also having youtube channel Name with LearnSchoolOnline. Traveling, watching movies, coding are the hobbies.