How To Redirect 404 Error To Home Page or Non Shopify URL To Home Page?

Highlighted
Tourist
7 0 3

Let's say I have a website www.example.com and this is designed by Shopify.

So how to redirect any non shopify URL for example- www.example.com/asjghjgwqsdjsjk to www.example.com.

Or any 404 error to www.example.com

Please Note: I have gone through 404 Redirects in this forum but it is not correct what I am looking for. It is written that if the product is out of stock then it will redirect to Home Page URL, which I don't want to do.

Your help highly appreciated and correct answer will be upvoted. Please share your knowledge.

Highlighted
Tourist
7 0 3

I am quite surprised to see that no Shopify Expert has not replied to my thread till now. Is this question so difficult to Shopify Experts?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
5704 1 326

You can create URL directs on your Navigation page. This creates actual redirects recognized by search engines. Search engines learn about the new URL for a page. That feature does not work with wildcards.

For any 404 Not Found that isn't redirected with a store URL redirect, then you can send customers over to your home page by adding the following HTML as close as you can to your opening head tag in your theme.liquid file:

{% if template == '404' %}<meta http-equiv="refresh" content="0;URL={{ shop.url }}" />{% endif %}

 

Highlighted
Tourist
7 0 3

Thank you so much Caroline... It worked nicely.... Again thank you and have wonderful days always.....

Best Regards

Kalu

Highlighted
Shopify Partner
6 0 2

It worked for me too, but there is an issue that first it shows redirection to 404 then it goes to homepage. How can i fix that it only go to homepage without going to 404 page first.

Highlighted
Shopify Partner
1 0 0

I have check its working for me but i have one issue which is every time page is refresh. so can you help me for that.

0 Likes
Highlighted
Tourist
4 0 0
Same thing happening for me. Did you manage to figure it out?
0 Likes
Highlighted
New Member
1 0 4

You can add this inside the head of the template.liquid file

{% if template == '404' %}
<script>window.location.href = '/';</script>
{% endif %}

 

Highlighted
New Member
1 0 0

Araya - perfect!

0 Likes
Highlighted
Tourist
3 0 1

This is perfect

0 Likes