Re: Redirect with rules

Can I create 301 redirects similar to htaccess rules?

Delio
Shopify Partner
18 0 1

Hello,

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)

ThePrimeWeb
Shopify Partner
2139 616 524

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 %}
<script>
window.location.href = '{{ redirect_url | within: site }}';
</script>

 

 

Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!