Copied to clipboard

Flag this post as spam?

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


  • Asger 25 posts 171 karma points
    Aug 17, 2016 @ 08:51
    Asger
    0

    // creates dublicate content (issue)

    Hi Umbraco Forum.

    Earlier i had help setting up the following rule to prevent www issues:

       <rewrite>
            <rules>
                <rule name="Redirect to non-www" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="www\.yourdomain\.com$" />
                    </conditions>
                    <action type="Redirect" url="http://yourdomain.com/{R:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    

    Now i would like to rewrite the statement to prevent dublicate content from urls containing // /\ and /

    I tried rewriting it, but without success.

    Hope someone can help! :)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Aug 17, 2016 @ 10:06
    Alex Skrypnyk
    1

    Hi Asger,

    Try to use Umbraco settings for this.

    Read more - https://our.umbraco.org/documentation/reference/config/umbracosettings/

    Thanks,

    Alex

  • Asger 25 posts 171 karma points
    Aug 17, 2016 @ 10:14
    Asger
    1

    Hi Alex.

    Thanks for your response. Im not quite sure what you refer to when you say "as mentioned in the comment above"? I only see your comment.

    Also im not quite sure in which file i should make this change that you suggest?

    And i have the issue with the /\ too, do you know why that is?

    Thanks :)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Aug 17, 2016 @ 10:16
    Alex Skrypnyk
    1

    And i have the issue with the /\ too, do you know why that is?

    I thought yes, but not sure :) what is it?

    Also im not quite sure in which file i should make this change that you suggest?

    /config/umbracoSettings.config file

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Aug 17, 2016 @ 10:17
    Alex Skrypnyk
    1

    I hope it will help you !

  • Asger 25 posts 171 karma points
    Aug 17, 2016 @ 11:13
    Asger
    1

    Hi Alex.

    Thanks for the input. The change helped so that umbraco no longer adds the / to the link, however in order to fix the issue with dublicate content i need to make a rewrite so it is impossible to access the page with the / or // in the end, do you know how to rewrite the above code to do that?

    Best regards and high fives!

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Aug 17, 2016 @ 11:46
    Alex Skrypnyk
    0

    Hi Asger,

    Happy to help!

    I'm little bit confused how did you get // and other bad links?

    Are they from external sites?

    Thanks,

    Alex

  • Asger 25 posts 171 karma points
    Aug 17, 2016 @ 11:48
    Asger
    101

    Hi Alex.

    Sorry i think im just bad at formulating my issue.

    I made this solution my self, which works perfectly:

                 <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>
    

    But thank you very much for your help! :)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Aug 17, 2016 @ 11:49
    Alex Skrypnyk
    1

    You are welcome!

    Great solution!

    Have a nice day.

Please Sign in or register to post replies

Write your reply to:

Draft