How can I correctly rewrite a URL with .aspx to a URL without .aspx?
<p>I have a site that currently uses the .aspx extension on its pages. It's getting a Joomla conversion and the .aspx extension will not work anymore. I need it so that if someone enters the .aspx extension, it will just get removed the URL so none of the SEO on the current site breaks.</p>

<p>For example, I need
www.arrc.com.php5-17.websitetestlink.com/services/managed-services.aspx
to be rewritten/redirected to
www.arrc.com.php5-17.websitetestlink.com/services/managed-services</p>

<p>This is what I have in my web.config:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;configuration&gt;
  &lt;system.webServer&gt;
    &lt;rewrite&gt;
     &lt;rules&gt;
      &lt;rule name="Migrate to PHP"&gt;
       &lt;match url="^([_0-9a-z-]+)\.aspx" /&gt;
       &lt;action type="Redirect" redirectType="Permanent" url="{R:1}" /&gt;
      &lt;/rule&gt;
      &lt;rule name="Rewrite .aspx"&gt;
         &lt;match url="^([_0-9a-z-]+)/?([_0-9a-z-]+)\.aspx" /&gt;
         &lt;action type="Redirect" redirectType="Permanent" url="{R:1}/{R:2}" /&gt;
      &lt;/rule&gt;
     &lt;/rules&gt;
    &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
&lt;/configuration&gt;
</code></pre>

<p>The first URL match is for any URLs that have a URL like services.aspx instead of services/managed-services.aspx</p>

<p>Whenever I go to www.arrc.com.php5-17.websitetestlink.com/services/managed-services.aspx it gives me an internal server error, but www.arrc.com.php5-17.websitetestlink.com/services.aspx rewrites correctly. What can I do to fix this?</p>
