RE: Canonical tags for upper case URL

thumbnail
Aravinth Kumar, modified 7 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
Hi All,
Canonical tags are not generated properly if i use upper case letter in the url, it gives only host and not the complete url.

For ex:
Working fine : if url is x.x.x.x:8080/car
<link data-senna-track="temporary" href="http://x.x.x.x:8080/car" rel="canonical">

Not working: if url is x.x.x.x:8080/Car Upper case used
<link data-senna-track="temporary" href="http://x.x.x.x:8080" rel="canonical">

I saw liferay uses PortalUtil.getCanonicalURL method to generate the canonical url. How it can be resolved. Any suggestions ?

Thanks in Advance.
thumbnail
Aravinth Kumar, modified 6 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
I have achieved it in below way. This may help someone in future.We need to override \tomcat-8.0.32\webapps\ROOT\html\common\themes\top_head.jsp file using hooks.
Existing code:<%String canonicalURL = PortalUtil.getCanonicalURL(completeURL, themeDisplay, layout);%>

<link data-senna-track="temporary" href="<%= HtmlUtil.escapeAttribute(canonicalURL) %>" rel="canonical" />
Modified code:<%String canonicalURL = PortalUtil.getCanonicalURL(completeURL.toLowerCase(), themeDisplay, layout);%>