简体   繁体   English

Joomla搜索404

[英]Joomla search 404

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

There is no module available AFAIK - at least not for 1.6. 没有可用的模块AFAIK-至少不适用于1.6。 But it is quite easy to do by yourself. 但是,自己做是很容易的。 You can use the solution in the joomla documentation. 您可以在joomla文档中使用该解决方案。 This is usable for any error code. 这可用于任何错误代码。

http://docs.joomla.org/Creating_a_Custom_404_Error_Page 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. 例如/ search在这种情况下。 The above is for 1.5, for 1.6 you need to use this: 以上是针对1.5的,对于1.6,您需要使用以下代码:

  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). 如果您正在使用apache,第二种可能的解决方案是在joomla安装的根目录中使用.htaccess文件修改-如果找不到一个可创建-并添加此代码段以重定向到您想要的错误代码404页面(网页未找到)。

# 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. Joomla错误页面通常由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. 您可以将其复制到JOOMLA / templates / system / error.php中以开始使用。

http://docs.joomla.org/Custom_error_pages http://docs.joomla.org/Custom_error_pages

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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