Disable ezPublish search functionality

58 views Asked by At

I'm using ezpublish 5.4.11. Our customer want us to disable the search engine. We managed to hide the input and button on the templates. Then, we'd like to disable access to search result page and to do it in a clean way (from a SEO point of view :permanent redirect to homepage). What is the best way to do this ? Besides, any other setting to update ?

1

There are 1 answers

0
harmstyler On

I assume you have access to Symfony? I did this for a client by creating a controller that throws a 404 exception. I then routed the search page to the 404 controller. Because symfony sits in front of eZ Publish, you can use symfony to disable any default eZ modules. Moreover, if you were to upgrade to Platform, this method of disabling the module would continue to work. Note that in my example I am preferring to 404 rather than redirect. You could also 410 or 301 the controller by changing the HTTP Exception returned.

The route config:

ez_content_search:
    defaults: { _controller: DefaultBundle:Default:notFound }
    path: /content/search

The controller:

/**
 * @throws NotFoundHttpException
 */
public function notFoundAction()
{
    throw $this->createNotFoundException();
}

Alternatively, if you want to disable a default module/view in the legacy stack alone, you can use the site.ini's SiteAccessRules block.

[SiteAccessRules]
Rules[]=access;disable
# If content/search module use current policy (denied)
Rules[]=module;content/search