Uppercase lowercase in URL canonicalization

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
zygissimo
New Member
New Member
Posts: 2
Joined: Fri Feb 12, 2016 4:19 pm

Uppercase lowercase in URL canonicalization

Post by zygissimo »

Hi everyone,

I have a client with old cms version and I have not have very deep knowledge in programming. Maybe you could help me.

I want to eliminate dublicate content in URL with upper and lower cases since they all are accessible by either:
1. Create a canonical tag in every single page pointing to itself only to the original URL (with lowercase). I've tried writing

Code: Select all

<link rel="canonical" href="{$node->url}"/> 
but no luck. I am getting a one weird link in all pages..
2. Or create 301 redirect in htaccess file. But some images I have contain capital letters in their name so the images are not displayed anymore.

Please help if you can.

Here's is what I am working with:
CMS Install Information
CMS Version 1.11.9

Installed Modules
CMSMailer 5.2.2
CMSPrinting 1.0.5
FileManager 1.4.3
MenuManager 1.8.6
MicroTiny 1.2.5
ModuleManager 1.5.5
News 2.13
Search 1.7.11
ThemeManager 1.1.8
TinyMCE 2.9.12
Gallery 1.6.1
FormBuilder 0.7.4
CGExtensions 1.37.3
CGSimpleSmarty 1.7
JQueryTools 1.2.5
Products 2.20
PDFGenerator 0.1
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Uppercase lowercase in URL canonicalization

Post by Dr.CSS »

This is in some of the default templates...

{if isset($canonical)}<link rel='canonical' href='{$canonical}' />{elseif isset($content_obj)}<link rel='canonical' href='{$content_obj->GetURL()}' />{/if}
zygissimo
New Member
New Member
Posts: 2
Joined: Fri Feb 12, 2016 4:19 pm

Re: Uppercase lowercase in URL canonicalization

Post by zygissimo »

Thank you very much. Could you also help me tweak this code a little bit so I could get canonical in the main page without trailing slash in the back?

I've modified your code a little bit to this:

{if isset($canonical)}<link rel='canonical' href='{$canonical}' />{elseif isset($content_obj)}<link rel='canonical' href='{$content_obj->GetURL()}/' />{/if}

Because I get all the links within canonical without slash at the back. And these are 301 redirects to the ones with the slash ant the back.

But with this code in the main page I get this result:
<link rel="canonical" href="http://www.mainpage.com//"
Post Reply

Return to “The Lounge”