Forum Archive - Add trailing slash to rel="canonical" overview pages

Add trailing slash to rel="canonical" overview pages
Jun 1, 2016 8:33 pm by mjbradley85
So I've finally configured the gtranslate delivery service to work with Wordpress on Windows IIS 7.5. However, I'm still having issues with the web.config rewrite rules. Currently, my website is setup to force trailing slashes so clicking on a foreign flag will successfully redirect the homepage from domain.com to domain.com/th/ But I receive a 404 error when I visit domain.com/th (no trailing slash). This wouldn't normally be an issue, except that domain.com/th (no trailing slash) is set as the canonical URL on the page. So search engines are told to find /th or /es when in fact, they're supposed to crawl the version with trailing slashes. My question is, how to change the canonical url on the translated pages to include a trailing slash? <link rel="canonical" href="http://www.finishlynx.com/th" /> should really be <link rel="canonical" href="http://www.finishlynx.com/th" /> so there are no 404 errors. Or at least it should redirect no slash to slash automatically. Here are my current IIS 7.5 web.config rewrite rules: <rule name="Redirects" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" /> </conditions> <action type="Redirect" url="{C:1}" appendQueryString="false" /> </rule> <rule name="Redirect finishlynx.com to www" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{HTTP_HOST}" pattern="finishlynx.com" /> </conditions> <action type="Redirect" url="http://www.finishlynx.com/{R:0}" /> </rule> <rule name="gtranslate1" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$" /> <action type="Redirect" url="/{R:1}/{R:3}" redirectType="Permanent" /> </rule> <rule name="gtranslate2" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$" /> <action type="Rewrite" url="/gtranslate/gtranslate.php?glang={R:1}&amp;gurl={R:2}" appendQueryString="true" /> </rule> <rule name="gtranslate3" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$" /> <action type="Redirect" url="/{R:1}/" /> </rule>
Re: Add trailing slash to rel="canonical" overview pages
Jun 7, 2016 1:14 pm by mjbradley85
Can anyone from the gtranslate team help me fix the canonical trailing slash issue?
Re: Add trailing slash to rel="canonical" overview pages
Jun 8, 2016 4:29 pm by Edvard
Hi, When I visit domain.com/th it redirects me to domain.com/th/ You need to find how canonical link is being generated and modify the PHP code to include / in the end. Thanks!
Re: Add trailing slash to rel="canonical" overview pages
Jun 8, 2016 5:38 pm by mjbradley85
I was able to fix the non trailing slash redirects, but I still cannot figure out how to change the canonical urls. I assumed this was generated automatically by gtranslate on the server side. Is this not the case? How are the canonical urls typically displayed for other gtranslate clients. Should they contain a trailing slash when properly configured? Are you suggesting it's an error with our rewrite/install rather than a standard feature of the gtranslate? Appreciate your help and patience.
Re: Add trailing slash to rel="canonical" overview pages
Jun 8, 2016 5:41 pm by Edvard
On your original website I can see this canonical meta for home page: <link rel="canonical" href="http://www.domain.com" /> it has no / in the end. It is not an error, everything is working fine, you just want / in the end, so if you want you may add. Thanks!

SIMILAR TOPICS

Combining manually translated French pages with GTranslateOct 16, 2018 2:24 pmReplies: 3Post by: oxygensmith
How to add rel="nofollow" to GTranslate links ?Sep 19, 2018 10:10 amReplies: 5Post by: agatti
Google doesnt index gtranslate pagesJul 23, 2012 4:44 amReplies: 21Post by: trotsak
Geotargetting pagesJan 18, 2018 8:48 pmReplies: 5Post by: challisc
<html dir="ltr" lang="no" prefix="og: http://ogp.me/ns#">Dec 19, 2017 7:35 amReplies: 2Post by: besybuy

Try GTranslate with a free 15 day trial