Is it possible to display a block only on a URL without any parameters? E.g. on:

  • my.site.org/search

but not on:

  • my.site.org/search?q=term

When I configure a block ('/admin/structure/block/manage/myblock') and set visibility for pages at: '/search' (see the picture), then the block is displayed on the page '/search?q=term' as well.

enter image description here

1 Answer 1


You can use condition_query it will give you an extra box where you can put query parameters like q=term

enter image description here

  • Thanks @GiorgosK. I hoped, that it is possible without an additional module. I need it in a project, where are allowed only modules, which are covered by the Drupal security advisory policy. So it looks like I have to find a workaround. E.g. the search results can be displayed on some other URL, like: search/results?q=term Commented Feb 26, 2018 at 9:36
  • 1
    well its either this or create your own implementation in a module or your theme. why would your implementation be more secure than a module already used by more than 186 sites?
    – GiorgosK
    Commented Feb 26, 2018 at 9:41
  • Generally there is at the moment too much custom code in the project. So for unimportant functionality it is not recommended to add new code. But your solution can be quite usefull for other projects. Commented Feb 26, 2018 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.