我们的Drupal站点默认的403,404页面都很丑陋,除非你经过专门定制。
为什么不让这些页面,为公益传递一份爱,为这个世界带来一份帮助?
公益404页面是由腾讯公司员工志愿者自主发起的互联网公益活动。参见:http://www.qq.com/404/
我们可以利用现成的Drupal模块,经过简单配置让我们的Drupal站点为公益奉献爱心。
这里介绍两种方式如何实现截图中的效果,不需要写一行代码。
方式一:(普通建站者,推荐。)
1:下载并启用customerror模块,连接如下:https://www.drupal.org/project/customerror
2:配置站点默认的404,403错误调用的页面。
到examples.com/admin/config/system/site-information,拖到页面底部,配置如下:
3:配置customerror。
打开example.com/admin/config/system/customerror (如果有问题,检查下customerror模块是否已经开启。)
将如下代码贴上并保存:
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>
4:检验配置。 随机输入一个不存在的url,比如example.com/asdfasdf看看页面是否是显示寻人信息。
方式二:(Drush方式,安装Drush的网站及懒人可以使用此种方式)
drush dl customerror drush en -y customerror drush vset site_403 "customerror/403" drush vset site_404 "customerror/404" drush vset customerror_403 '<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>' drush vset customerror_404 '<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>'