Copied to clipboard

Flag this post as spam?

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


  • Chris 69 posts 75 karma points
    Dec 25, 2010 @ 07:29
    Chris
    0

    Google and extension-less urls

    Hi,

    When developing new Umbraco sites, I always use directory urls (without the aspx extension).

    However, I just discovered that in some cases the .aspx pages are indexed by google instead of the extension-less equivalent. Is there any way to prevent this?

    Also when I browse to a specific page, for example www.mydomain.com/about, i notice that it is also accessible through www.mydomain.com/about.aspx. If possible I would like to have only the extension-less url available (with the .aspx page doing a 301 redirect).

    Does anyone have some guidelines about this?

    Thanks a lot!

    Chris

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 25, 2010 @ 11:08
    Lee Kelleher
    0

    Hi Chris,

    You can handle this in IIS7 (using a custom rewrite rule), or using a rule in the UrlRewriting.config.

    I don't have an example to hand right now... but can find one later if you need?

    Cheers, Lee.

  • Chris 69 posts 75 karma points
    Dec 27, 2010 @ 08:25
    Chris
    0

    Hi Lee,

    Thanks for your reply! I suppose something like the following would do the trick?

    <rule name="RemoveExtension" enabled="true" stopProcessing="true">
    <match url="(.*)\.(aspx)$" />
      <action type="Redirect" url="{R:1}" />
    </rule>

    Or is this not a 301 redirect?

    Does google also see http://www.mydomain.com/about (without ending slash) and http://www.mydomain.com/about/ (with ending slash) as different urls or not?

    Thanks,

    Chris

     

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Dec 27, 2010 @ 10:34
    Matt Brailsford
    0

    Hey Chris,

    You could also try using the Cononcial meta tag package which adds a canonical meta tag to all your pages, and tells google which version should actually be indexed.

    http://our.umbraco.org/projects/developer-tools/canonical-meta-link-package

    Matt

  • Ove Andersen 435 posts 1541 karma points c-trib
    Dec 27, 2010 @ 11:04
    Ove Andersen
    1

    Google indexes http://www.mydomain.com/about (without ending slash) and http://www.mydomain.com/about/ as two different web pages

    According to http://www.alistapart.com/articles/slashforward/ you should always append a trailing slash.

    Here is a rewrite rule for that:

                    <rule name="Remove ASPX Extension" enabled="true" stopProcessing="true">
                        <match url="^(?!umbraco/)(.+)\.(aspx)$" />
                        <action type="Redirect" url="{R:1}/" redirectType="Permanent" />
                    </rule>
                    <rule name="Add trailing slash" enabled="true" stopProcessing="true">
                        <match url="(.*[^/])$" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Redirect" url="{R:1}/" redirectType="Permanent" />
                    </rule>

    Note: I have changed the RemoveExtension slightly to not touch anything in the /umbraco/ folder, as it messes stuff up in the backend.

  • Chris 69 posts 75 karma points
    Dec 28, 2010 @ 10:36
    Chris
    0

    Thanks for these great insights, guys!

    Good to learn about the canonical link package, Matt. Very nice for doing some extra SEO optimization! I will certainly use this in the future. Do all search engines support the canonical tag already?

    For now, I'll just stick with the good old redirect rules that Ove shared here. These probably spared me a serious regex headache...! ;-)

     

  • Chris 69 posts 75 karma points
    Dec 31, 2010 @ 08:35
    Chris
    1

    Hi, just as a reference: The redirect rules work great, but i had to make one small adjustment in order to keep my rest extensions working. This is exluding the /base path from the redirect rule. See code below.

            <rule name="Remove ASPX Extension" enabled="true" stopProcessing="true">
    <match url="^(?!umbraco/)(?!base/)(.+)\.(aspx)$" />
    <action type="Redirect" url="{R:1}/" redirectType="Permanent" />
    </rule>

    Thanks again for the great help!

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft