Link to home
Start Free TrialLog in
Avatar of sanjshah12
sanjshah12Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Rewrite URL

Hi,

I am trying to add a few URL rewrites, as an example, I have the following in my webconfig:

 
<rewrite>
        <rules>
            <rule name="SpecificRewrite" stopProcessing="true">
                <match url="~/Users/Apples" />
                <action type="Redirect" url="~/Users/Products.aspx?category=apples" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>

Open in new window



I am running through VS for testing but just get a page not found (HTTP Error 404.0 - Not Found) when I navigate to http://localhost:56192/Users/Apples

Any help is appreciated.

Regards,
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sanjshah12

ASKER

many thanks zc2, that now works!

How am I able to add multiple rules? I tried duplicating but get an error


 <rewrite>
        <rules>
            <rule name="SpecificRewrite" stopProcessing="true">
                <match url="Users/Apples" />
                <action type="Redirect" url="/Users/Products.aspx?category=apples" redirectType="Permanent" />
            </rule>
            <rule name="SpecificRewrite" stopProcessing="true">
                <match url="Users/Apples" />
                <action type="Redirect" url="/Users/Products.aspx?category=apples" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>

Open in new window

Those two rules have the same name "SpecificRewrite". May be that caused the error?
Apologies, I forgot to change the name!
Many thanks zc2
You're welcome