简体   繁体   中英

Joomla search 404

当您输入不存在的页面时,是否有扩展名可将您重定向到搜索页面?

There is no module available AFAIK - at least not for 1.6. But it is quite easy to do by yourself. You can use the solution in the joomla documentation. This is usable for any error code.

http://docs.joomla.org/Creating_a_Custom_404_Error_Page

if (($this->error->code) == '404') {
header('Location: /search');
exit;
}

The part behind the Location: is where you redirect to the page you want. eg /search in this case. The above is for 1.5, for 1.6 you need to use this:

  if ($this->error->getCode() == '404') {
          header('Location: /search');
          exit;
  } ;

The second possible solution if you are using apache is to use modify the .htaccess file in the root of the joomla installation - if you can't find one create one - and add this snippet to redirect to the page you want for error code 404 (page not found).

# CUSTOM ERROR PAGES
 ErrorDocument 404 URL /search
# END CUSTOM ERROR PAGES

If you need more assistance please don't hesitate to ask.

Joomla error pages are typically handled by JOOMLA/templates/YOUR TEMPLATE/error.php. You can either customize that page or you can put a redirect on the page to get visitors where you want them to end up. Since most people don't include one of these in their template, it defaults back to the system file. You can copy the on in JOOMLA/templates/system/error.php to get started.

http://docs.joomla.org/Custom_error_pages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM