php - Creating SEO canonical paths (none absolute) -
i using code generate canonical link seo purposes
<link rel="http://www.mydomain.com$_server[script_name]"> so lets file go http://www.mydomain.com/thisfolder/?this=that&yes=no
the canonical link display as
http://www.mydomain.com/thisfolder/?this=that&yes=no
what want no matter variables being passed in url display canonical as
http://www.mydomain.com/thisfolder/
i have tried both request_uri , script_name in $_server[]; both same thing. there way can achieve whether not using correct name $_server[]; or there anyway this?
try $_server['path_info']
contains client-provided pathname information trailing actual script filename preceding query string, if available. instance, if current script accessed via url http://www.example.com/php/path_info.php/some/stuff?foo=bar, $_server['path_info'] contain /some/stuff.
Comments
Post a Comment