Reputation: 19880
I have following rewrite rule to append .aspx
extension if url has no extension.
<rule name="SimpleRewrite" stopProcessing="true">
<match url="^(.*(?<=/)([^/.]*))$" />
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
However the rule is not working:
Error HTTP 500.52 - URL Rewrite Module Error.
The expression "^(.*(?<=/)([^/.]*))$" has an invalid syntax.
However, this regular expression works in .NET. What regular expressions are supported by IIS Url Rewrite Module? How to make positive lookbehind assertion?
Upvotes: 4
Views: 3364
Reputation: 91502
perhaps .*/[^/.]+$
would serve your needs? the rewrite would just be "{R:0}.aspx"
edit (in response to comment): if you want to include simple filenames, you could write
^(.*/)?[^/.]+$
Upvotes: 2
Reputation: 300
It sounds like there may be a simpler solution to your problem that won't require regular expressions, but if not, this may help.
Quick: Try a mod-rewrite clone IIS plugin like ISAPI_Rewrite Lite for complex regular expresions.
Long: A year or so ago I did an ISS deployment of a Drupal site, in which all the primary, secondary and I believe tertiary links were to be handled by Drupal, but deeper legacy content was supposed to be served as normal ( instead of being taken over by Drupal 404 ).
We used ISAPI_Rewrite 3, a "port" ( compatible syntax ) of Apache's mod_rewrite to do the directing between the legacy content and drupal, with a series of Rewrite filters and rules that would check for any content matching the URL in a legacy folder before letting Drupal handle the rest.
http://www.helicontech.com/isapi_rewrite/
ISAPI_Rewrite Lite is free, and had all the features I needed. Plus you can shop around, Helicon isn't the only company that has created a Mod-Rewrite clone plugin for IIS.
Upvotes: 1