When I request sitemap.xml
, I'm getting No route found for "GET /sitemap.xml"
. I need to serve sitemap.xml
from the /web
folder. So some reason Symfony starts to look for a route. I think config.yml
is messed up. I'm using FOSRestBundle which works fine but might interfere with routing.
Relevant parts from the config.yml
:
framework:
translator: { fallback: en }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection:
enabled: false
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session:
save_path: %kernel.root_dir%/var/sessions
fragments: ~
fos_rest:
cache_dir: %kernel.cache_dir%/fos_rest
routing_loader:
default_format: json
service:
templating: templating
serializer: jms_serializer.serializer
serializer:
serialize_null: false
param_fetcher_listener: force
body_listener: true
body_converter:
enabled: true
format_listener:
rules:
- { path: '^/api', fallback_format: json }
- { path: '^/', priorities: [ 'html', '*/*'], fallback_format: html, prefer_extension: true }
view:
default_engine: twig
formats:
json: true
view_response_listener: forcebundle
unauthorized_challenge: ""
access_denied_listener:
json: true
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
'Symfony\Component\HttpKernel\Exception\HttpException': true
Nope. The issue here is in your .htaccess
or similar rewrite mechanism.
The default .htaccess
that ships with Symfony inncludes these rules:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
which means, "if a an actual file exists, just serve it". In your case this rule is not applied for some reasons, so everything is passed on to app.php
and Symfony routing, but Symfony has no /sitemap.xml
route, thus the 404 error.