Can I create 301 redirects similar to htaccess rules?

Shopify Partner
11 0 0


is it possible to create 301 redirect with something similar to the htaccess rules? 

For example I want that all url with /shop/category/product-name will be redirect to /products/product-name

Reply 1 (1)

Shopify Partner
2057 594 466

Hey @Delio,

If the two links already work, then possible.
You can use the code below. But if the "/products/product-name" is something you want to create, it probably isn't going to work out. 


{% if condition %}
{% assign redirect_url = '/products/product-name' %}
{% endif %}
window.location.href = '{{ redirect_url | within: site }}';



Was I helpful?

Buy me a coffee


Need help with your store? or check out the website
Check out our interview with Shopify!