Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Caley 14 posts 125 karma points
    Dec 08, 2022 @ 13:38
    Caley
    0

    No Trailing slashes gives server error

    Hi! When trying to ensure that all my urls are without trailing slashs, I get a server error?

    Here is what I have done.

    I have added this to my web.config

    <rule name="RedirectTrailingSlash" stopProcessing="true"> <match url="(.*?)/+$" /> <conditions> <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> <add input="{REQUEST_METHOD}" pattern="^PUT$" negate="true" /> <add input="{REQUEST_METHOD}" pattern="^DELETE$" negate="true" /> <add input="{REQUEST_METHOD}" pattern="^PATCH$" negate="true" /> <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" /> <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>

    This works perfectly. But in my template all links are still with an trailing slash So I found the requesthandlersettings and added "RequestHandler": { "AddTrailingSlash": false } to my appsettings.json. Now every link has no trailing slash.

    So far everything is working perfectly. But only locally in my test environment – when I upload the appsettings.json to production I get a 500 server error.

    Can anyone point me in the right direction, and give me clue about whats wrong?

  • Caley 14 posts 125 karma points
    Dec 08, 2022 @ 20:30
    Caley
    100

    Hmm... I tried to move the RequestHandler in the appsettings.json and suddenly it works! I have no clue why.. but i'm happy.

Please Sign in or register to post replies

Write your reply to:

Draft