Back to list

404 Error Solution - Frequently Asked Questions Module

Some of our customers are facing 404 error when trying to open some of FAQ’s module pages. It occurs because of compatibility issues of the FAQ module and Pretty Url module. 

 

So, if you meet such a problem, this instruction will help you to solve the issue.

 

Firstly, you need to open file “/override/classes/Dispatcher.php” and  find the line “$this->controller = str_replace('-', '', $controller);”. 

Add above this line the following code:

 

if (Module::isEnabled('faqs') == true) {
  require_once _PS_MODULE_DIR_ . 'faqs/faqs.php';
  $faq_home_page_name = faqs::getHomePageName();
  if (preg_match('/^/'.$faq_home_page_name.'/$/', $this->request_uri)) {
    $_GET['fc'] = 'module';
    $_GET['module'] = 'faqs';
    $_GET['controller'] = 'display';
    $controller = 'display';
    $this->front_controller = self::FC_MODULE;
  } elseif (preg_match('/^/'.$faq_home_page_name.'$/', $this->request_uri)) {
    $_GET['fc'] = 'module';
    $_GET['module'] = 'faqs';
    $_GET['controller'] = 'display';
    $controller = 'display';
    $this->front_controller = self::FC_MODULE;
  } elseif (preg_match('/^/'.$faq_home_page_name.'/([_a-zA-Z0-9-pL]+).html$/', $this->request_uri, $matches)) {
    $_GET['fc'] = 'module';
  $_GET['module'] = 'faqs';
    $_GET['controller'] = 'display';
    $_GET['category'] = $matches[1];
    $controller = 'display';
    $this->front_controller = self::FC_MODULE;
  } elseif (preg_match('/^/'.$faq_home_page_name.'/([_a-zA-Z0-9-pL]+)/([_a-zA-Z0-9-pL]+).html$/', $this->request_uri, $matches)) {
    $_GET['fc'] = 'module';
    $_GET['module'] = 'faqs';
    $_GET['controller'] = 'display';
    $_GET['category'] = $matches[1];
    $_GET['question'] = $matches[2];
    $controller = 'display';
    $this->front_controller = self::FC_MODULE;
  } elseif (preg_match('/^/'.$faq_home_page_name.'/search/(.+)$/', $this->request_uri, $matches)) {
    $_GET['fc'] = 'module';
    $_GET['module'] = 'faqs';
    $_GET['controller'] = 'display';
    $_GET['search'] = $matches[1];
    $controller = 'display';
    $this->front_controller = self::FC_MODULE;
  }
}

 

It should look like this:

 

 

Secondly, you need to open file - “/modules/faqs/faqs.php” and find the following line of code: “private function getAdminDir($full_path_to_admin_dir)”.

 Add above this line the following code:

 

  public static function getHomePageName() 
  {
    return self::$SEOHomePageId;
  }

 

It should look like this: 

 

 

After you make these changes the problem will be solved. Thank you for your attention.

Usefulness of the answer:
0/0