php - Creating canonical URLs with custom route-classes -


I am trying to implement the canonical url and to combine with custom route classes.

URL-SACAME is something like this:

  / category-x / article / 123 / category-y / article / 123   

I am creating a custom route - the expansion of the class Zend_Controller_Router_Route_Regex and checks that the article is 123 and the correct category-name is included in the URL. If the article is in 123 square-X and the user is reaching square-y, then I want to redirect to the correct URL.

But there is no clear possibility to do this directly to the roads. What is the best practice approach here?

I often do this in my action controller like something ...

  // Get / Category-Y / Article / 123 $ $ article- & gt; URL is generated, and it contains / category-x / article / 123 if (this-> --request-> getRequestUri ()! = $ Article-> URL) {return $ this- & gt; ; _helper-> Redirector-> GoToUrl ($ paragraph-> url); }   

In this example, $ article-> The url will need to be generated from your database data when I drag the object ID, then I often use it to verify a correct slug.

You want to use custom routing class instead of using reggax, you could sub-class it).

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -