Can we code URL redirects in Shopify?

Aliza11
Tourist
23 0 1

Can we create URL redirects through code in shopify?

Replies 13 (13)

JohnMiller12
Shopify Partner
2 0 0

Hello,

 

I hope you are well.

 

I have reviewed your requirement and in order to redirect the URL we need to replace the URLs from the backend and request google to crawl for the same.

 

 

Aliza11
Tourist
23 0 1

We have redirected one domain to the primary domain and it's done but we need to redirect it to the particular page of the primary domain.

Aliza11
Tourist
23 0 1

We have redirected one domain to the primary domain and it's done but we need to redirect it to the particular page of the primary domain.

jigneshjivani
Shopify Partner
17 1 2

Can you tell exactly which URL you want to redirect and to which URL?

Thank You,
If helpful then please Like and Accept Solution.
Email | Hire Me | Skype
Aliza11
Tourist
23 0 1

For example I have already redirect www.abc.com to www.xyz.com but now I have to redirect www.abc.com to www.xyz.com/page (on a particular page of xyz site)

jigneshjivani
Shopify Partner
17 1 2

Add below code before </head> tag in theme.liquid file.

{% if request.host == 'www.abc.com' %}
<script>
window.location.href = 'www.xyz.com/page';
</script>
{% endif %}
Thank You,
If helpful then please Like and Accept Solution.
Email | Hire Me | Skype
Aliza11
Tourist
23 0 1

It's not working

Aliza11
Tourist
23 0 1

We have redirected www.crafttculture.com to www.habitt.com through AWS panel. Now we want to redirect http://www.crafttculture.com to https://habitt.com/pages/craftt

Also the above mentioned is not working.

jigneshjivani
Shopify Partner
17 1 2

Remove AWS panel redirect and Add below code before </head> tag in theme.liquid file.

{% if request.host == 'http://www.crafttculture.com' or request.host == 'www.crafttculture.com' %}
<script>
window.location.href = 'https://habitt.com/pages/craftt';
</script>
{% endif %}

 

Thank You,
If helpful then please Like and Accept Solution.
Email | Hire Me | Skype
Aliza11
Tourist
23 0 1

It is still not working

 

jigneshjivani
Shopify Partner
17 1 2

Add www.crafttculture.com url to your shopify store account Domains.

Thank You,
If helpful then please Like and Accept Solution.
Email | Hire Me | Skype
Aliza11
Tourist
23 0 1

You mean I should add www.crafttculture.com url to www.habitt.com shopify store account Domain?

Aliza11
Tourist
23 0 1

MicrosoftTeams-image (4).png

 We have done this already