简体   繁体   中英

How to edit canonical meta tag for category from http to https in magento 1.9.x

I tried adding code in category ->custom Design->Custom Layout update

<reference name=”head”>
    <action method=”addLinkRel”>
       <rel>canonical</rel>
          <href>https://yourwebsiteadress.co.uk/page-name.html</href>
    </action>
</reference>

but it is not working.....

Is there any alternative way to convert all http to https without manually adding code into it. If i am trying to adding this syntax catalog-> manage categories -> Custom Design ->custom layout update showing xml data is invalid please help me out i am new in magento

Default way

If you use the default theme and doesn't change it too much, it should not need manually adding codes, go to " admin - system - Configuration - GENERAL - Web - Use Secure URLs in Frontend ", set it as " Yes ".

Go to " admin - system - Configuration - Catalog - Catalog - Search Engine Optimizations - Use Canonical Link Meta Tag For Categories ", set it as " Yes ".

Then it would work.

Manually add canonical

The " admin - system - Configuration - Catalog - Catalog - Search Engine Optimizations - Use Canonical Link Meta Tag For Categories " dropdown should be set to No , so that you can manually add canonical tags to Custom Layout Update box on your category page.

<reference name=”head”>
<action method=”addLinkRel”>
<rel>canonical</rel>
<href>https://example.com/page-name.html</href>
</action>
</reference>

Your "Custom Layout" codes should be "https...", you write it as "http", lack "s".

You can write the below code in magento root .htaccess file under <IfModule mod_rewrite.c> tag which redirect all the http url on https

## HTTP to HTTPS redirection
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/downloader.*$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/downloader.*$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM