301 Redirects for Already-Written URLs

janessaallen
janessaallen used Ask the Experts™
on
Hi, I have IIS 8 and url rewrite rules in place to make the urls friendly by converting the .aspx pages and parameters to a new, rewritten URL.  however, some of my maps have values that have changed, forcing me to have to do 301 redirects from one friendly URL to another.  Here is an example:

From: www.domain.com/friendly-url  needs to be redirected
To: www.domain.com/friendly-url-2

How do you get from one rewritten URL to another?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DevOps Manager
Top Expert 2011
Commented:
Capture the {REQUEST_URI}  as /friendly-url and place a rule to forward to your other location.

ex:
 <rule name="URI to URI" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="^/friendly-url$" />
                    </conditions>
                    <action type="Redirect" url="http://{HTTP_HOST}/friendly-url2/" />
                </rule>        

-Hades666

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial