skip to Main Content

I am using the below redirect rule so as to remove the trailing slash in the URL. The trailing slash is removed but the redirect is happening to HTTP URL and not to HTTPS URL. Can you please help to update the below redirect rule so as to redirect to the HTTPS URL?

 <rule name="Remove trailing slash" stopProcessing="true">
      <match url="(.*)/$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{R:1}" />
    </rule>

2

Answers


  1. <action type="Redirect" redirectType="Permanent" url="https://{SERVER_NAME}/{R:1}" />
    
    Login or Signup to reply.
  2. In .NET Core you can use next approach

    var options = new RewriteOptions()
        .AddRedirect("(.*)/$", "$1", 301 /* Moved Permanently */);
    app.UseRewriter(options);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search