Use the "app_dev.php" at the end of your URL to debug and check what route is being used at the bottom. For example I show "route1" here:

Then in your twig template you can use something like this:
{% if app.request.attributes.get('_route') == 'route1' %}
<h1>test</h1>
{% endif %}
I verified this works. I'm using Symfony3 though.
Maybe also try instead of "app.request.attributes.get()", try these:
- app.request.pathinfo
- app.request.uri
See if those work.
Also if the route is indeed null, try:
{% if app.request.attributes.get('_route') == '' %}
<h1>test</h1>
{% endif %}