I have on my site set umbracoUseDirectoryUrls and addTrailingSlash to true so all paths look like this.
/test/
/test/sub/
But if I manually remove the trailing slash, the page is still responding on ex. "/test/sub". This is actually bad for SEO, because search engines could see this as duplicate content.
/test and /test/sub is treated as files while /test/ and /test/sub/ as directories.
The solution would be to add a 301 redirect, if the trailing slash is missing.
But why do Umbraco not work that way by default, when the setting clearly says, there should be a trailing slash?
Does anyone have a quickfix for this, where taking into account the querystring?
It might be a little long winded but what about adding a Url Rewrite rule to your web.config to force a trailing slash? You'll need to Url Rewrite IIS module installed for this to work.
Just an FYI on Pete's last post - as is it seems to cause problems with the DocTypeGridEditor Preview in the backoffice. It ends up injecting front-end template HTML into the DTGE preview. The trailing slash seems to throw the preview rendering off.
Add trailing slash - but still respons without
Hi Umbracians
I have on my site set umbracoUseDirectoryUrls and addTrailingSlash to true so all paths look like this.
/test/ /test/sub/
But if I manually remove the trailing slash, the page is still responding on ex. "/test/sub". This is actually bad for SEO, because search engines could see this as duplicate content.
/test and /test/sub is treated as files while /test/ and /test/sub/ as directories.
The solution would be to add a 301 redirect, if the trailing slash is missing.
But why do Umbraco not work that way by default, when the setting clearly says, there should be a trailing slash?
Does anyone have a quickfix for this, where taking into account the querystring?
Best regards Benjamin Ravn
Hi Benjamin
Don't know if you can perhaps use the 301 tracker package to fix this?
However I'm not sure why Umbraco does not make sure to add the trailing slash under the hood. Maybe it's something no one has ever thought about.
Perhaps it's a good idea to file a feature request for having this changed on the issue tracker http://issues.umbraco.org/issues
If you create an issue please put the link in this thread so others can go and vote it up as well should they come across this post.
Have a nice friday! :)
/Jan
It might be a little long winded but what about adding a Url Rewrite rule to your web.config to force a trailing slash? You'll need to Url Rewrite IIS module installed for this to work.
I think the above could be simplified to the follow for Umbraco 7.4.3 and up:
I tweaked this a bit after using this in the wild to the following:
Just an FYI on Pete's last post - as is it seems to cause problems with the DocTypeGridEditor Preview in the backoffice. It ends up injecting front-end template HTML into the DTGE preview. The trailing slash seems to throw the preview rendering off.
To fix this you can add:
In case people start noticing funny behaviour!
is working on a reply...