Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

Preventing duplicate pages - /mypage and /mypage/


Reply

8 Posts   1746 Views

Avatar
w1

5 June 2009 at 3:28pm (Last edited: 8 June 2009 8:36am), Community Member, 21 Posts

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

Avatar
w1

9 June 2009 at 3:16pm Community Member, 21 Posts

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

Avatar
Mo

10 June 2009 at 3:05am Community Member, 509 Posts

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

Avatar
banal

10 June 2009 at 7:02pm Community Member, 901 Posts

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]

Avatar
Mo

10 June 2009 at 8:43pm Community Member, 509 Posts

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.

Avatar
Web Designer Perth

29 June 2009 at 3:20pm Community Member, 49 Posts

Sitemap generator: http://www.xml-sitemaps.com/

Avatar
w1

29 June 2009 at 4:02pm Community Member, 21 Posts

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

Avatar
w1

29 June 2009 at 4:44pm Community Member, 21 Posts

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