We build site upon Yii (1.1.13); it's car pare parts shop & transaction management engine. When given for its SEO inspection to the SEO company and the company concluded the result:
The assortment in the db is dynamicly updated daily.
The company suggested to solve the dynamic url generator issue or not to use it in favour of user-friendly URLs/SEO-friendly URLs.
How to fix dynamic url generator failures and if it's possible to use smth. else as suggested?
Url management configuration has been off so far:
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
When i uncommented it the site works well yet some of subsystem menus does not function cause are bound to some GET parameters...
Recently did something like this for a shop.
Usually you will do this:
1) For each dynamic url dynamically make it's clean url arternative
2) Redirect from old to clean url.
3) PROFIT!
Now as for the details:
The most tricky part is understanding whether the new url can be formed and if so, redirect to it. I think you can do this either in a customUrlRule (which is a bit dirty) or a controller (which I like more).
Let us assume you've chosen a controller: In a controller's action, determine whether there is a new url user came from. If there is AND REQUEST URL!==NEW URL you are just proceeding with controller logic. If not, you are redirecting to the new url. I think it should be comfortable if
1) both url types are processed with the or different controller and action, and include the logic described above.
2) You are using some kind of method to give the url of a new and old type, passing the same parameters to them. For example, you may use Yii::app()->createUrl($params) for new type of Url, and some custom method, i.e. $myModelInstance->createUrl($params)
3) New urls are being built and processed with custom URL rule
4) In your url manager, you have your custom rule for new urls and ordinary rule for older urls in this precedence.
To sum it up:
If the user goes from old url, the controller action is executed, where some additional checks are made. We are checking if a new url can be built, we also can check some additional things, i.e. sync with some additional seo url database, to know whether this url needs to be redirected. If new url can be built - we redirect to it. The browser requests a request, which is parsed with your custom url rule, and corresponding controller and action is executed.