2

I need to redirect from example.com/landing to example.com/blog/info/landing. I wrote a rule in web.config

<rule name="Atlanta redirect" stopProcessing="true">
  <match url="landing" />
  <action type="Redirect" url="https://www.example.com/blog/info/landing" redirectType="Permanent" />
</rule>

but if url matches "landing" word then it redirect to example.com/blog/info/landing too.

For example correct redirect: example.com/landing -> example.com/blog/info/landing

Wrong redirect example.com/somepage/1/landing -> example.com/blog/info/landing

1 Answer 1

2

Use a regex that matches /landing exactly:

<match url="^landing$" />

(IIS removes the leading / when doing regex matches)

The ^ and $ symbols are Regex Anchors that match the start and end of the string respectively.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.