Copied to clipboard

Flag this post as spam?

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


  • J 447 posts 864 karma points
    Jul 04, 2019 @ 09:01
    J
    0

    addTrailingSlash not working?

    I have seen the setting

    <addTrailingSlash>true</addTrailingSlash> 
    

    which should add a slash at the end of the the URL but it doesn't? I have refreshed the app-pool, stopped and restarted the site but if i type in the url as

    mysite.com/aboutus

    then it doesnt add a slash at the end.

    Any ideas?

  • David Challener 80 posts 444 karma points c-trib
    Jul 08, 2019 @ 15:14
    David Challener
    0

    Hi,

    I normally use a rewrite rule myself but the documentation https://our.umbraco.com/documentation/reference/config/umbracoSettings/

    says: addTrailingSlash As mentioned in the comment above, this will add a trailing slash to the url when umbracoUseDirectoryUrls in the web.config file is set to "true". If you don't want to have a trailing slash when directory urls are in use simply just set the value to false.

    so try to set this setting as well if not already?

    HTH, David

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jul 08, 2019 @ 15:18
    Alex Skrypnyk
    0

    hi J

    "addTrailingSlash" adds trailing slash to the end of URLs rendering by IPublishedContent.Url - method.

    If you just type in browser and you want to be redirected to the URL with a slash - you need to use a redirect or rewrite rule.

    Why do you want to add trailing slash?

    Thanks,

    Alex

  • J 447 posts 864 karma points
    Jul 09, 2019 @ 11:10
    J
    0

    @David Challener - Yes that is the documentation i referred to and i have umbracoUseDirectoryUrls and addTrailingSlash both set to true.

    @Alex Skrypnyk - I ran a report and it states the pages created are being looked as duplicate (with and without a slash), so i thought to have slashes at the end of the URLs.

    Is there a rule/addon i could use as only some pages are being highlighted but i cant see a reason why. I just dont want any of the existing pages to become 404's.

    Thanks

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jul 09, 2019 @ 14:33
    Alex Skrypnyk
    1

    Hi J

    You are right, the page with "/" and without - 2 different pages for google crawlers, so it's better to do the redirect for all sites.

    Thanks Alex

  • J 447 posts 864 karma points
    Jul 09, 2019 @ 15:31
    J
    0

    Thanks Alex, how could i do that? Is there a plugin i could use? I tried doing it via Web.config but had looping errors, so i didnt want to make the issue any worse.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jul 09, 2019 @ 15:56
    Alex Skrypnyk
    1

    Hi J

    Use this rewrite rule:

    <rule name="Remove 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> 
    

    Thanks, Alex

  • David Challener 80 posts 444 karma points c-trib
    Jul 09, 2019 @ 15:43
    David Challener
    0

    This thread should be able to give a couple of ways of achieving this

    https://our.umbraco.com/forum/developers/extending-umbraco/22807-Add-Trailing-Slash-Url-Rewrite

    Thanks, David

  • J 447 posts 864 karma points
    Jul 10, 2019 @ 10:11
    J
    0

    Thanks guys, the code i'm currently using is (i think i need the slash as theres less issues overall for the site)

    <rule name="Add 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>
    

    however some pages that i dont want the / to append to, does. Is there a way to exclude some directories from adding a slash to or file extensions?

  • David Challener 80 posts 444 karma points c-trib
    Jul 10, 2019 @ 10:19
    David Challener
    102

    Yes, this is the rule from v8 and you can see that when using negate="true" you're saying you don't want to include it in the match. So this is saying ignore the umbraco folder and install folder etc.

    <rule name="Add trailing slash" stopProcessing="true">
          <match url="(.*[^/{2,}])$" ignoreCase="true" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/install/" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/([0-9]+).aspx" negate="true" />
            <add input="{URL}" pattern="^.*\.(asp|aspx|axd|asmx|css|js|jpg|jpeg|png|gif|mp3|htm)$" negate="true" ignoreCase="true" />
            <add input="{URL}" pattern="/Base" negate="true" />
            <add input="{URL}" pattern="cdv=1" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
        </rule>
    

    HTH, David

  • Jebastin 42 posts 92 karma points
    Sep 04, 2019 @ 12:21
    Jebastin
    0

    Thank you so much David Challener. You saved my time!

Please Sign in or register to post replies

Write your reply to:

Draft