On different CMS, sometimes URL are built with parameters, with a slash at the end or without it. Because of this, sometimes, during the SEO progress, duplicate pages appear, which should not be. Therefore, you should use rel=canonical to avoid problems with SEO promotion.
Below is the code that should be inserted between <head></head> or done on function.
First we determine whether the site is opened by a secure protocol or not.
Then we collect our URL from the protocol ($protocol), domain ($_SERVER[‘SERVER_NAME’]) and links ($_SERVER[‘REQUEST_URI’]).
Next, we determine whether the URL has parameters or not ($_SERVER[‘QUERY_STRING’]). If there is, delete them, they are not needed for the tag.
And at the end (not necessarily) remove the slash if the links are formed without it. It is also useful not to use 301 redirect, which conflicts with the processing of 404 pages on different CMS.
If you have any questions, want to get individual advice or you have an interesting offer, you can contact via the feedback form.
Or write to the email firstname.lastname@example.org