Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us

SEO trick (for developers)

edited March 2011 in Questions
For example, news. Just example, no explanations


// class.newsconttroller.php // file

// public function Index($Code) {
if (is_numeric($Code)) {
// elseif(... other check for news category url code, etc.

// public function View() { // method
// trick
$NewsModel = Gdn_NewsModel();
$Story = $NewsModel->GetID($NewsID);
$NewsStoryURL = 'news/'.$Story->NewsID.'/'.Gdn_Format::Url($News->Title); // or you can use Clean() method
$CanonicalUrl = $this->CanonicalUrl(Url($NewsStoryURL, True));
if ($NewsStoryURL != $this->SelfUrl) Redirect($CanonicalUrl, 301);


Sign In or Register to comment.