2016-09-26 19 views
0

我想爲我的cakephp站點www.jegeachi.com生成xml鏈接。我通過xml-sitemaps.com從這個在線工具生成了這個消息,我被告知這個xml文件應該在http://jegeachi.com/sitemap.xml處可見。所以,我做以下步驟: 在配置/ routes.php文件,我補充一下:如何在cakephp url中添加擴展名?

Router::parseExtensions('html', 'rss','xml'); 

Router::connect("/sitemap", array('controller' => 'frontends', 'action' => 'sitemap', 'ext' => 'xml')); 

在前端控制器我補充一下:

function sitemap() { 
     $this->layout ='ajax'; 
     $this->render('sitemap.xml'); 
    } 

最後我上傳的sitemap.xml到視圖/前臺應用文件夾。但是http://jegeachi.com/sitemap.xml這個鏈接沒有顯示我的xml。我的過程是錯誤的?我應該怎麼做?

回答

0

爲什麼不

Router::connect("/sitemap", array('controller' => 'frontends', 'action' => 'sitemap')); 

然後調用,而是用分機鏈接。

該擴展將根據需要自動添加。

相關問題