Jump to content

canonical url and https issue


Recommended Posts

I have used Prestashop on a number of site but have just notice don a particular site that Google is caching all the pages as https not http. Obviously I don't want the whole site to be viewwd in ssl. I looked into what could be causing it and I think it is the canonical url module.

 

In a previous Prestahop version (1.3.1.1) the canonicalurl.php packaged with it has this major difference:

 

f[color="#000088"]unction[/color] hookHeader[color="#666600"]([/color]$params[color="#666600"])[/color] 
[color="#666600"]{[/color] 
[color="#000088"]global[/color] $smarty[color="#666600"],[/color] $protocol_link[color="#666600"],[/color] $rewrited_url[color="#666600"];[/color] 

 $canonicalUrl[color="#666600"]=[/color] [color="#660066"]Configuration[/color][color="#666600"]::[/color][color="#000088"]get[/color][color="#666600"]([/color]'CANONICAL_URL'[color="#666600"]);[/color]    $ps_request[color="#666600"]=[/color] str_replace[color="#666600"]([/color]__PS_BASE_URI__[color="#666600"],[/color] [color="#008800"]''[/color][color="#666600"],[/color] $_SERVER[color="#666600"][[/color][color="#008800"]'REQUEST_URI'[/color][color="#666600"]]);[/color] 

[color="#000088"]if[/color] [color="#666600"]([/color]strlen[color="#666600"]([/color][color="#660066"]Configuration[/color][color="#666600"]::[/color][color="#000088"]get[/color][color="#666600"]([/color]'CANONICAL_URL'[color="#666600"]))[/color] [color="#666600"]>[/color] [color="#006666"]0[/color][color="#666600"])[/color] 
 $smarty[color="#666600"]->[/color]assign[color="#666600"]([/color]'CANONICAL_URL'[color="#666600"],[/color] $protocol_link[color="#666600"].[/color]$canonicalUrl[color="#666600"].[/color]$_SERVER[color="#666600"][[/color][color="#008800"]'REQUEST_URI'[/color][color="#666600"]]);[/color] 
[color="#000088"]return[/color] $this[color="#666600"]->[/color]display[color="#666600"]([/color]__FILE__[color="#666600"],[/color] 'canonicalurl.tpl'[color="#666600"]);[/color] 
[color="#666600"]}[/color]

 

whereas the same section of code in the file packaged with version 1.3.7.0 reads:

 

p[color="#000088"]ublic[/color] [color="#000088"]function[/color] hookHeader[color="#666600"]([/color]$params[color="#666600"])[/color] 
[color="#666600"]{[/color] 
[color="#000088"]global[/color] $smarty[color="#666600"];[/color] 

 $canonicalUrl[color="#666600"]=[/color] [color="#660066"]Configuration[/color][color="#666600"]::[/color][color="#000088"]get[/color][color="#666600"]([/color]'CANONICAL_URL'[color="#666600"]);[/color] 
 $ps_request[color="#666600"]=[/color] str_replace[color="#666600"]([/color]__PS_BASE_URI__[color="#666600"],[/color] [color="#008800"]''[/color][color="#666600"],[/color] $_SERVER[color="#666600"][[/color][color="#008800"]'REQUEST_URI'[/color][color="#666600"]]);[/color] 
 $protocol_link[color="#666600"]=[/color] [color="#666600"](([/color][color="#660066"]Configuration[/color][color="#666600"]::[/color][color="#000088"]get[/color][color="#666600"]([/color][color="#008800"]'PS_SSL_ENABLED'[/color][color="#666600"]))[/color] [color="#666600"]?[/color] [color="#008800"]'https://'[/color] [color="#666600"]:[/color] [color="#008800"]'http://'[/color][color="#666600"]);[/color] 
[color="#000088"]if[/color] [color="#666600"]([/color]strlen[color="#666600"]([/color][color="#660066"]Configuration[/color][color="#666600"]::[/color][color="#000088"]get[/color][color="#666600"]([/color]'CANONICAL_URL'[color="#666600"]))[/color] [color="#666600"]>[/color] [color="#006666"]0[/color][color="#666600"])[/color] 
  $smarty[color="#666600"]->[/color]assign[color="#666600"]([/color]'CANONICAL_URL'[color="#666600"],[/color] $protocol_link[color="#666600"].[/color]$canonicalUrl[color="#666600"].[/color][color="#660066"]Tools[/color][color="#666600"]::[/color]htmlentitiesUTF8[color="#666600"]([/color]rawurldecode[color="#666600"]([/color]$_SERVER[color="#666600"][[/color][color="#008800"]'REQUEST_URI'[/color][color="#666600"]])));[/color] 
[color="#000088"]return[/color] $this[color="#666600"]->[/color]display[color="#666600"]([/color]__FILE__[color="#666600"],[/color] 'canonicalurl.tpl'[color="#666600"]);[/color] 
[color="#666600"]}[/color]

 

As you can see it checks if ssl is enabled and then for some reason makes the canonical url https instead of http which is not wanted. How can I change it to not do this? I am very wary of making any changes that could be detrimental to the site's Google rankings. I am hoping after changing the canoncial url to be http rather than https then google will pick up the change. Otherwise I can't set upi a 301 redirect as the site will not go into ssl for the checkout pages as it should.

 

Any advice on dealing with Google would be most appreciated! I obviously want to switch from http to https without losing any page rankings.

Link to comment
Share on other sites

Get rid of the canonical URL module (which is useless at best, and hurtful at worst).

 

Try this http://www.prestashop.com/forums/topic/39736-module-duplicate-url-redirect-redirect-all-duplicate-and-non-seo-friendly-urls-to-the-default-friendly-url/ it does all the redirects using 301 (which will tell search engines the page has moved, and won't lose page rank).

 

It has a special redirect only for search engines on all https page to the regular http version.

Link to comment
Share on other sites

I have already updated the canonical url to ignore https and set a 301 redirect to redirect https to http manually excluding all the pages that actually need it. A complete pain in the **rse to do, but finally done nevertheless!

 

When Google has updated its cache to use the http then I will set up robots.txt to tell the serach engines to ignore https as described in another thread

Link to comment
Share on other sites

Hmm, I have been wondering why on pages like history.php (but not addresses.php) I get an SSL error on IE. It seems it could be the redirect I have set up - any ideas why this would throw up such an error?

 

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI}
!^/(order(.*)\.php|authentication\.php|my-account\.php|modules/referralprogram/referralprogram-program\.php|init\.php|address\.php|addresses\.php|identity\.php|modules/blockwi
shlist/managewishlist\.php|modules/blockwishlist/mywishlist\.php|modules/blockwishlist/view\.php|modules/loyalty/loyalty-program\.php|(.*)payment\.php|history\.php|discount\.p
hp|modules/mailalerts/myalerts\.php|modules/paypal/redirect\.php|contact-form\.php)$
RewriteRule ^(.*)$ http://mydomain.co.uk/$1 [R=301,L]

Link to comment
Share on other sites

  • 5 months later...

I take that back - it seemed to work then I got the error again. Does anyone have any clue? I really need to 301 to stop google caching the https and to keep the ranking of the pages

 

Hello,

 

I have the same problem, Google have indexed my site as https but not has http.

 

Did you find a solution?

 

Regards.

Andres.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...