How to remove 'X-Robots-Tag' http header in Symfony 5

2.4k views Asked by At

I am developing a project using the Symfony 5 framework. I have deployed that code to production. When I am trying to add website to google search engine then I am getting:

Error "No: 'noindex' detected in 'X-Robots-Tag' http header"

I have changed the environment from dev to production but still I am getting the same error. I have tried to disable disallow_search index but this method is also not working

disallow_search_engine_index: false

How can change X-Robots-Tag header in Symfony 5?

2

There are 2 answers

1
Muamet Islami On

Make sure you set the APP_ENV to prod in .env file like this:

APP_ENV=prod

And clear your cache with this command:

APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear

Apparently Symfony blocks search engines if it is in development mode

source

0
Ilyich On

Maybe you tried to disallow search engine index in the wrong file.

This worked for me:

config/packages/framework.yaml

framework:
    # ...
    disallow_search_engine_index: false