Reputation: 295
I am trying to redirect permanent this using IIS rewrite
www.domain.com/category/sub-category/product-slug OR www.domain.com/category/product-slug
to
Old URLs are from magento2 while new site is on nopCommerce
Basically I want every URL to be redirected to domain.com/product-slug. How I can achieve this?
Any help will be highly appreciated.
Upvotes: 0
Views: 315
Reputation: 5205
You can try below rules:
<rule name="test1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.test.com" />
<add input="{REQUEST_URI}" pattern="^/([^/]+)/([^/]+)/([^/]+)$" />
</conditions>
<action type="Redirect" url="http://www.test.com/{C:1}/{C:3}" />
</rule>
and
<rule name="test2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.test.com" />
<add input="{REQUEST_URI}" pattern="^/([^/]+)/([^/]+)$" />
</conditions>
<action type="Redirect" url="http://www.test.com/{C:1}/{C:2}" />
</rule>
The body cannot contain "http://www. domain.com", so I use www.test.com instead.
Upvotes: 1