Sitemap.xml file for Google search
- rickylorenco
- Member | 3
How to add sitemap without clashing with router system.
Sitemap should be easy to read for Google crawling.
- jiri.pudil
- Nette Blogger | 1029
Hello. The simplest way is to create or generate an actual sitemap.xml file in the web server's document root. Web servers are commonly configured to serve static files and delegate to the PHP application only if the file is not found, so it shouldn't clash with any PHP routing system.
- Michal Hlávka
- Member | 190
You can create a simple sitemap.xml
route heading to
SitemapPresenter with the Default action containing something like
public function actionDefault()
{
$file = '/assets/sitemap.xml';
if (is_file($filename)) {
$this->sendResponse(new TextAsFileResponse(file_get_contents($filename)));
}
}
https://github.com/…Response.php
EDIT: I am looking at the documentation of TextAsFileResponse, there is an example with file response.
Last edited by Michal Hlávka (2019-04-24 13:12)