public function init() {
parent::init();
// Perform a redirect if not at the correct URL (just a difference in the trailing slash, to be safe).
$uri = $_SERVER["REQUEST_URI"];
$correct = $this->Link();
if ($uri != $correct && rtrim($uri, "/") == rtrim($correct, "/")) return $this->redirect($correct, 301);
}
I wonder if this is the sort of thing that belongs in core? Maybe provide a private static setting of "$require_trailing_slash" (or something) with the default value set to true.
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.
Marijn
Kampf
Exadium - Online Marketing & Web Development
www.exadium.com
--
Google has said time and time again, duplicate content issues are rarely a penalty. It is more about Google knowing which page they should rank and which page they should not. Google doesn’t want to show the same content to searchers for the same query; they do like to diversify the results to their searchers.
Yes, an unrecoverable 404 failure when there's an easy automated method of recovery is profoundly worse than 3 lines of bloat. You assessment is correct.
I actually prefer the unslahed url as being the "correct" version. From Apache's perspective, the / historically meanst to return the index of the requested folder, ie return index.html or display a list of contained files. The resource itself doesn't have a slash at the end.
Using canonical tags is very risky because pages with custom actions need special rules, so unless you're very careful you can cause silent errors.
Using a 301 is slow, depending on whether every link ends up being 301ed due to the default output or not. However, when deciding to have or not have a slash, the best rule of thumb is to not have one. You can make the most generic rule which won't start breaking links to actual files.
You'll give yourself more of a penalty with Google by slowing your site through constant 301s, or 404s on arbitrarily different URLs, or erroneous canonicals.
The easiest way to explain it to a client is that Google works to provide the most relevant and best experience to a search user to find what they are looking for. Does consistently removing or adding a trailing slash affect the experience of the user? No. But slowness does.
Ultimately, the delay to do a 301 (via htaccess) will be pretty neglagable, but if you're arguing over unifying trailing slashes on URLs, the delay from 301s is much more of an issue to focus on.
If you have a client or their agency saying you have to do it, just charge for it and do it. I'm not sure it's worth perpetuating this myth on dev mailinglists to do that.
Dan