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
    Jul 28, 2016 @ 10:42
    Asger
    0

    301 redirect to remove www in url.

    Hi umbraco forum.

    I used to work mainly with php, but transitioned to umbraco. Some of the things i used to control in the .htaccess file, im having trouble doing in the umbraco cms.

    Genereally im having trouble understanding the whole setup with the web.config file, and the config folder.

    Also i cant seem to make the 301 redirect work, to remove www from my url. I have tried various solutions from 4 different sources, but it just wont work.

    I hope you can help me out :)

    Best regards.

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Jul 28, 2016 @ 14:31
    Dennis Adolfi
    100

    Hi Asger!

    The web.config is a ASP.NET web application file, and the config folder is Umbraco specific settings files. Is there anything in specific that you fine confusing about these two?

    When it comes to your 301, this one is used in one of our site and it works great. It should be placed in your web.config, within configuration/system.webServer:

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

    Hope it helped!

    Have a great day!

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Aug 01, 2016 @ 11:10
    Dennis Adolfi
    0

    Maybe a given, but just in case: Did you replace "yourdomain.com" with the url for the website?

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

    Hi Dennis! Thank you very much. At first, when i implemented your code, it didnt work, but it turns out i made a typo, so now it works perfectly! Thank you so much :)

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Aug 01, 2016 @ 11:14
    Dennis Adolfi
    1

    Glad it worked out for you Asger!!

    Have a great day! Hope you enjoy Umbraco so far!! :)

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

    Hi Dennis.

    Thanks for helping the last time. Do you happen to know how i can remove // from the url aswell with a similar rule?

    Thanks :)

Please Sign in or register to post replies

Write your reply to:

Draft