2

In my appication i used to URL Rewrite using Intelligencia. My URL Pattern is

<rewrite url="~/([A-Za-z0-9-_ ]+)$" to="~/xxxxxx.aspx?id=$1"/>

Now i want if the URL doesn't contain iphonestatelist,iphonepropertytype then only it should redirect.

I have used this below code but it does not working.

<rewrite url="~/(^((?!\b(iphonestatelist|iphonepropertytype)\b).)*[A-Za-z0-9-_ ]+)$" to="~/xxxxxx.aspx?id=$1"/>

Eg: The below URL dont want to Rewrite

www.xxxx.com/abc/sef/iphonestatelist

The right URL to Rewrite

www.xxxx.com/FX1234

2 Answers 2

3

Try

<rewrite
   url="^(?!.*?\b(?:iphonestatelist|iphonepropertytype)\b)~/([A-Za-z0-9-_ ]+)$" 
   to="~/xxxxxx.aspx?id=$1"
/>

Generally: To check if a string contains (or does not contain) a certain sub-string, use a look-ahead (or negative look-ahead, respectively) like this:

^(?=.*?pattern-reqired)pattern-you-look-for
^(?!.*?pattern-disallowed)pattern-you-look-for

These patterns can also be chained

^(?!.*?not-this)(?!.*?not-that)pattern-you-look-for
Sign up to request clarification or add additional context in comments.

Comments

0

Try <rewrite url="^(?!.*?\b(?:iphonestatelist|iphonepropertytype)\b)~/([A-Za-z0-9-_ ]+)$" to="~/xxxxxx.aspx?id=$1" />

Generally: To check if a string contains (or does not contain) a certain sub-string, use a look-ahead (or negative look-ahead, respectively) like this:

`^(?=.*?pattern-reqired)pattern-you-look-for

^(?!.*?pattern-disallowed)pattern-you-look-for These patterns can also be chained

^(?!.?not-this)(?!.?not-that)pattern-you-look-for`

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.