Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple IIS Redirection expression ("*") throws an error: The expression "*" contains a repeat expression

I have the world's simplest regular expression: *

I put it in a web site in IIS because I want one of the sites to be a proxy, and the others to serve locally. So, the web.config is:

<system.webServer>
    <rewrite> 
      <rules>
        <rule name="AllRewrite" stopProcessing="true">
          <match url="*" />
          <action type="Rewrite" url="http://tom-pc/{R:0}" />
        </rule>
      </rules>
    </rewrite> 
</system.webServer>

However, that throws this error:

The expression "" contains a repeat expression (one of '', '?', '+', '{' in most contexts) that is not preceded by an expression.

Any ideas?

like image 883
Tom Lianza Avatar asked Jun 02 '26 16:06

Tom Lianza


1 Answers

The error says it all. Your regular expression is invalid. The * is a repeat character (zero or more times). You should indicate which character is allowed to be repeated zero or more times. You probably want any character, so your regular expression should be: .*

<match url=".*" />

To answer your other question about proxying, it's not possible to proxy by rewriting to another host name. You can only rewrite to other URI's on the same server. To proxy with IIS you have to install the ARR (Application Request Routing) module.

like image 94
Marco Miltenburg Avatar answered Jun 05 '26 13:06

Marco Miltenburg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!