简体   繁体   中英

URL Rewrite Substring

How would I substring the request url in a rewrite config?

For example: www.domain.com/some-request) -> www.domain.com/some-request

Just removing one letter from the end of the url.

Edit : I want to be able to do this from the url rewrite module config like so:

<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions><add input="{HTTPS}" pattern="^OFF$" /></conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

Like so:

string url = "www.domain.com/some-request)";
string sub = url.Substring(0, url.Length - 1);

DotNetFiddle

Or if you know the last character will always be a ) , just do:

"www.domain.com/some-request)".TrimEnd(')');

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