Hi Everyone
I am working on a project where I have a search results page. I have rewritten the url.
My url:
www.xyz.com/city/area/search/category/cs-tCbQIY8hMYQ-TT-3d
Now here if remove the last part from the url (after the /) i.e.
www.xyz.com/city/area/search/category I get an error 404 page not found.
How can I avoid this error by redirecting the user to an existing page.
I know this is possible
<customErrors mode="RemoteOnly" defaultRedirect="~/Error">
<error statusCode="500" redirect="~/Error" />
<error statusCode="404" redirect="~/NotFound" />
</customErrors>
But is it possible to redirect in all situations
www.xyz.com/city/area/search/category/cs-tCbQIY8hMYQ-TT-3d
www.xyz.com/city/area/search/category/
www.xyz.com/city/area/search/
www.xyz.com/city/area/
www.xyz.com/city/
Do I have to create page for each possibility?
Please guide.
Thanks
What I have tried:
The rule I am using in webconfig
<rule name="city and category">
<match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)$" />
<action type="Rewrite" url="/searchresults.aspx?city={R:1}&area={R:2}&type={R:3}&query={R:4}&cc={R:5}" redirecttype="Permanent" />
</rule>