Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Preventing duplicate pages - /mypage and /mypage/

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1651 Views
  • w1
    Avatar
    Community Member
    21 Posts

    Preventing duplicate pages - /mypage and /mypage/ Link to this post

    www.mysite.com/mypage and www.mysite.com/mypage/

    If you check your silverstripe site, you will find that most likely you can browse to either and they both will be seen

    How can that be prevented - so just the /mypage/ works - it is becoming an a duplicated content with google. Webmaster tools tell us that each page has the same title - description etc, which is frowned upon and not good seo

    Is there a solution to prevent possibility of www.mysite.com/mypage being viewed and producing a 404 error

    cheers
    Peter

  • w1
    Avatar
    Community Member
    21 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    Ok - no response

    New question then

    What sitemap.xml generator are people using? I may be able to resolve the issue by using a different generator
    If someone from silverstripe could reply that would be good - each of the file names end with / in http://silverstripe.org/sitemap.xml

    cheers
    Peter

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    A properly generated sitemap should get rid of your issue.

    What version of SIlverstripe are you using? There is a googlesitemap module available in the Silverstripe svn, and it is also bundled with 2.3.1.

    Hope that helps,

    Mo

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    Regarding your original question.
    You could either redirect URLs without trailing slash to the one with slash (put this in your .htaccess):


    RewriteCond %{REQUEST_URI} !/$
    RewriteRule .* %{REQUEST_URI}/ [R=301,NC,L]

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

    .. or you could only accept URLs with a trailing slash (the following code only redirects URLs with a trailing slash to SilverStripe. All others are up to the webserver to handle and will usually result in a 404 error):

    RewriteRule ^(.*/)?$ sapphire/main.php?url=%1&%{QUERY_STRING} [L]

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    I don't know if redirecting to a 404 would be wise, someone may type your URL from memory, but forget the last slash. In that situation the user would get a page not found and not understand why.

  • Web Designer Perth
    Avatar
    Community Member
    49 Posts
  • w1
    Avatar
    Community Member
    21 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    Thanks - that is what I was using. I have a solution from them - I will share as follows:

    this worked:
    In Do not parse URLs: I added
    .*mypage$

    so only indexes /mypage/ rather than both /mypage/ and /mypage

    cheers
    Peter

  • w1
    Avatar
    Community Member
    21 Posts

    Re: Preventing duplicate pages - /mypage and /mypage/ Link to this post

    and we found out what the cause of the xml sitemap generating those duplicated pages.

    The sitemap page (mysite/code/SiteMap.php) had been customised to produce some xml metadata for DigitalNZ to trawl content pages and was missing a trailing slash

    Another SS lesson learned

    cheers
    Peter

    1651 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.