Custom Canonical URL
Permalink
I'm using concrete5 - 5.6.1.2. I wrote a php function for canonical URL for SEO purpose.
My C5 pages is like
1. example1
. page1
. page2
2. example2
. page1
. page2
If I add a page to the site, it will be visible at:
example1.com/example1/page1
example2.com/example2/page1
I need to remove that example1,example2 in canonical URL.
public function canonical($c){ global $current_domain; $cPath = $c->getCollectionPath(); $canonicalURL = BASE_URL; $canonicalURL.= DIR_REL; $canonicalURL.= URL_REWRITING?"":"/index.php"; $canonicalURL.= $cPath; $canonicalURL .= "/"; $pageIndentifierVars = array('keywords','fID','tag','productID'); $canonicalVars = array(); foreach($pageIndentifierVars as $var) if($_REQUEST[$var]) $canonicalVars[]= $var.'='.$_REQUEST[$var]; if( count($canonicalVars) ) $canonicalURL.= '?' . join(',',$canonicalVars); return $canonicalURL; }
My C5 pages is like
1. example1
. page1
. page2
2. example2
. page1
. page2
If I add a page to the site, it will be visible at:
example1.com/example1/page1
example2.com/example2/page1
I need to remove that example1,example2 in canonical URL.