301 strip aspx from URL in IIS

GoodCode
GoodCode used Ask the Experts™
on
We changed our blog and now the url's don't have .aspx on the end of them but the URL is still the same otherwise. So

/blog/post/Using-Memory-Theory-to-Increase-Inbound-Results.aspx.

becomes

/blog/tips/using-memory-theory-to-increase-inbound-results

I'd like to 301 all of the old url's to the new link.

This is the rule I tried but it' redirects to the 404 page:

  <rule name="Rewrite old blog to PHP format (compound route)" stopProcessing="false">
          <match url="([^/]+)/([^/\?]+)\.aspx$" />
          <action type="Rewrite" url="index.php?route={R:1}&amp;page={R:2}" redirectType="Temporary" />
        </rule>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
To clarify, do all of the old urls include /blog/post and all the new ones are /blog/tips ?

Author

Commented:
Oh good catch I didn't even notice that. All of the old url's are blog/post and the new urls are blog/category  but the biggest category is tips so I can just have blog/tips be the default.

Author

Commented:
I apologize just tested it and it works even if you put post instead of the category.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Kamal KhaleefaInformation Security Specialist

Commented:
try to use the built in url mapping in the iis

Author

Commented:
How would I do that? I'm in the rewrite map section but I'm not sure what to put for the original value and new value.
Commented:
Here's the rewrite script that worked in case anyone's looking for this down the road:

                <rule name="Remove aspx" stopProcessing="false">
                    <match url="(.*)\.aspx\.?" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="{R:1}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>

Open in new window

Author

Commented:
It works.

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