Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Canonical tags for upper case URL
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.
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.
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);%>
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);%>
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™