Tuesday 15 January 2013

php - Redirect to dynamic sitemap or generate it through yiic? -



php - Redirect to dynamic sitemap or generate it through yiic? -

i want render dynamic sitemap yii site. i've failed in url manager:

'urlmanager'=>array( 'showscriptname'=>false, 'rules'=>array( 'sitemap.xml/*'=>'/site/sitemapxml', array('site/sitemapxml', 'pattern'=>'sitemap.xml', 'urlsuffix'=>''), ...

so turned .htaccess , added redirect this:

redirect 301 /app3/sitemap.xml http://tarex.ru/app3/index.php/?r=site/sitemapxml

another alternative generate sitemap.xml file through an extension in terms of yiic command. more time/recourse efficient?

first of all, rule incorrect, utilize instead:

'rules' => array( '/sitemap.xml' => '/site/sitemapxml', ... )

now, regarding question, doesn't matter much, way prefer, each of them has own cons , pros.

controller action option

pros:

easy implement , sustain. it's action, won't forget how sitemap generated in system.

cons:

dynamic content, therefore, lower performance.

solution: utilize coutputcache filter caching. add together filter sitecontroller:

public function filters() { homecoming array( array( 'coutputcache + sitemap', 'duration' => 24 * 60 * 60 // cache 24 hours ), ); }

don't forget configure cache component in configuration file. utilize cfilecache that. read corresponding section of definitive guide yii if you're not familiar topic.

it's pretty flexible solution, can extend illustration create reading caching duration configuration file if needed.

yiic option

pros:

sitemap.xml static file, served more efficiently web server

cons:

need update regularly , command process need utilize else except framework, requires monitoring well

solution: utilize cron job generate sitemap.xml.

although final decision highly depends on particular details of project, generally, i'd stick first approach.

php .htaccess yii sitemap

No comments:

Post a Comment