I used RewriteOptions to add "/" to end all urls, but when publishing to the iis server I get a "page does not redirect correctly" error.
i using this
var options = new RewriteOptions() //add '/' to end of url
.AddRedirect("(.*[^/])$", "$1/")
.AddRedirectToHttpsPermanent();
app.UseRewriter(options);
CodePudding user response:
Can you suggest a suitable pattern?
Well, assuming you have already installed
Configure URL Rewrite Pattern and Rules:
As, so far your requirement is to add additional slash /
of your website, Thus,you can set this (.*[^/])$
pattern on your URL Rewrite module in IIS as below:
Steps for configuration:
- Select your site in IIS
- Double Click on URL Rewrite under HTTP Features Table
- Click On Add Rules(s) top right
- Select Append Or remove the trainin slash symbol
- Select Appended if does not exist from the dropdown
- Click OK
Note: You can customize your rules as well. If you encounter any concern on this you can have a look below screen capture how to do it.
If you still need more further assistance, you could have look on our official document here