Announcement

Collapse
No announcement yet.

How do I set a dynamic canonical URL?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I set a dynamic canonical URL?

    I've been doing the following:

    HTML Code:
    <mvt:if expr="l.settings:page:code EQ 'CTGY'">
    <link rel="canonical" href="https://www.site.com/mm5/merchant.mvc?Screen=CTGY&Category_Code=&mvta:category:code;">
    <mvt:elseif expr="l.settings:page:code EQ 'PROD'">
    <link rel="canonical" href="https://www.site.com/mm5/merchant.mvc?Screen=PROD&Product_Code=&mvta:product:code;" /> 
    <mvt:elseif expr="l.settings:page:code EQ 'SFNT'">
    <link rel="canonical" href="https://www.site.com" /> 
    </mvt:if>
    We have both "www" and "non-www", so I need to send the canonical to the www version.

    Before I was redirecting all www to non-www, but this messed up the store. I'd rather not mess with .htaccess and just do a canonical.

    Is there a way to just get the current page and create a canonical link?

    #2
    Are you using legacy SEO settings? If so, it's best to migrate to URI management.

    If you're using URI management, can't you do something like this?

    Using URI management opens up some variables/entities (see bold below):
    <mvt:if expr="'CTGY' CIN l.settings:page:code">
    <link rel="canonical" href="&mvte:category:link;" itemprop="url">
    <mvt:elseif expr="'PROD' CIN l.settings:page:code">
    <link rel="canonical" href="&mvt:product:link;" itemprop="url">
    <mvt:else>
    <link rel="canonical" href="&mvte:urls:_self:auto;" itemprop="url">
    </mvt:if>


    https://docs.miva.com/how-to-guides/...uri-management

    https://www.miva.com/blog/how-to-con...tore-to-https/

    Miva support would likely help you with .htaccess rules (redirecting to secure www -- it's very simple) if you don't feel comfortable editing it yourself.
    -Ryan
    Last edited by RTHOMASDESIGN; 06-09-20, 02:12 PM.

    Comment

    Working...
    X