简体   繁体   中英

IIs rewrite rule append value to querystring

I am trying to make a rule for URL rewrite in IIS all day long,but none of my rules are working ..

I want to make rewrite url to transform for these types of Url

http://localhost:2811/Search/S%2fqIMmjstZg%3d/VehicleDetails.aspx To http://localhost:2811/Search/VehicleDetails.aspx?mid=S%2fqIMmjstZg%3d

http://localhost:2811/Search/yYut%2f%2fBrHa8%3d/VehicleDetails.aspx To http://localhost:2811/Search/VehicleDetails.aspx?mid=yYut%2f%2fBrHa8%3d

http://localhost:2811/Search/nNLApdJeWJI%3d/VehicleDetails.aspx To http://localhost:2811/Search/VehicleDetails.aspx?mid=nNLApdJeWJI%3d

with following rewrite rules

<rewrite>
        <rules>
            <rule name="QueryString">
                <match url="^Search/([_0-9a-z-%=\+\$]*)$/VehicleDetails.aspx" />
                <action type="Rewrite" url="Search/VehicleDetails.aspx?mid={R:1}" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>

But its not working..Help Please!!!

You have wrong patten. I suggest you following:

/Search/([^/]*)/VehicleDetails.aspx$

Now explanation (from end)

  1. /VehicleDetails.aspx$ - static text, which is on the end of string
  2. ([^/]) - everything except "/"
  3. /Search/- static text (you coluld try to add ^ in the begging but be careful with / after)
  4. You can test your expression in IIS UI: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM