Copied to clipboard

Flag this post as spam?

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


  • Kim 9 posts 29 karma points
    Feb 23, 2011 @ 08:54
    Kim
    0

    301 Redirect domain.dk to www.domain.dk

    Hi,

    I have a problem I can't figure out how to set up a 301 redirect that redirect from the version of af page like

    domain.dk/examplepage to www.domain.dk/examplepage (adds the www to the url) and also how to redirect from

    www.domain.dk/examplepage/ to www.domain.dk/examplepage (removing the "/") inside UrlRewriting.config

  • Doug Mackay 56 posts 155 karma points
    Feb 26, 2011 @ 00:33
    Doug Mackay
    1

    Not sure about removing the trailing slash but one of the following rules will 301 redirect the non www address to the www address.

    Only enable one of these rules. The first rule will 301 redirect domain.dk to www.domain.dk, the second rule will 301 redirect anything that's not www.domain.dk to www.domain.dk

     

     

    <!-- SEO: Redirect from the domain without www to the domain with www-->
    <add name="seoCanonical"
            virtualUrl="http://domain.dk/(.*)"
            rewriteUrlParameter="ExcludeFromClientQueryString"
            destinationUrl="http://www.domain.dk/$1"
            redirect="Domain"
            redirectMode="Permanent"
            ignoreCase="true" />

    <!-- SEO: Redirects from any domain to the standard domain-->
    <add name="seoCanonical"
            virtualUrl="http://(?!www\.domain.dk).*?/(.*)"
            rewriteUrlParameter="ExcludeFromClientQueryString"
            destinationUrl="http://www.domain.dk/$1"
            redirect="Domain"
            redirectMode="Permanent"
            ignoreCase="true" />
  • Kim 9 posts 29 karma points
    Feb 28, 2011 @ 11:15
    Kim
    0

    Great Thanks! I will test it!

  • LeaUK 34 posts 55 karma points
    Feb 28, 2011 @ 13:58
    LeaUK
    0

    Or you can use IIRF with an .irf file in each domain root (assuming IIS6)

    Example of .irf file:

    # remove the #'s to enable the lines of code

    # example of .com domain 301 rewrite

    # RewriteCond %{HTTP_HOST} ^mydomain\.com$ [I]
    # RedirectRule ^/(.*) http://www.mydomain.com/$1 [R=301]


    # example of .co.uk domain 301 rewrite

    # RewriteCond %{HTTP_HOST} ^mydomain\.co\.uk$ [I]
    # RedirectRule ^/(.*) http://www.mydomain.co.uk/$1 [R=301]

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Mar 01, 2011 @ 13:32
    Tim
    0

    If you want to remove the trailing slash, you can use the following rule:

    <add name="rewriteFolderSlashes"
          virtualUrl="^~/((?!umbraco/).[^?]*)/$" 
          rewriteUrlParameter="ExcludeFromClientQueryString"
          destinationUrl="~/$1" redirect="Application"
          ignoreCase="true"  redirectMode="Permanent"/>

  • Giorgos Grispos 145 posts 179 karma points
    Jul 16, 2012 @ 22:44
    Giorgos Grispos
    0

    Hi all,

    Just follow the solution and yes it does work fine however my server is nearly dead as 300 different redirects from old urls to new seems to put the server in a very busy work. So in my opinion it's not proper for serious things, maybe for jsut a generic redirect would be fine but just for this.

    Cheers, Giorgos

  • Ghufran Ahmad 17 posts 73 karma points
    Oct 09, 2015 @ 05:58
    Ghufran Ahmad
    0

    Thanks so easy

Please Sign in or register to post replies

Write your reply to:

Draft