wordpress网站遇到404错误常见方法
WordPress 404页面跳转到特定页面的方法
第一种方式
打开WordPress网站模版里边的404.php,如果该404.php不存在,那么就新建一个文件叫做404.php,然后拷贝以下代码进这个页面:
<?php header("Status: 301 Moved Permanently"); header("Location: ".get_bloginfo('url')."#301-redirect-from-404-page"); ?> <?php header("Status: 301 Moved Permanently"); header("Location: ".get_bloginfo('url')."#301-redirect-from-404-page"); ?>
(2013年1月22日更新)不好意思这里第一种方式里边的 header(“Status: 301 Moved Permanently”); 并不会实现真正的301跳转,而是返回了302跳转,现更正如下:
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')."#301-redirect-from-404-page"); ?> <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')."#301-redirect-from-404-page"); ?>
上边代码中的#301-redirect-from-404-page,主要用来通过网站统计系统统计哪些流量是来自404页面跳转过来的。
第二种方式
拷贝以下代码到404.php页面里边,可以跳转404页面到任意你设定的页面,替换其中的xxx为你的域名和页面URL即可:
<?php header("Status: 301 Moved Permanently"); header("Location: "); ?>
<?php header("Status: 301 Moved Permanently"); header("Location: "); ?>
(2013年1月22日更新)不好意思这里第一种方式里边的 header(“Status: 301 Moved Permanently”); 并不会实现真正的301跳转,而是返回了302跳转,现更正如下:
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: "); ?>
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: "); ?>
wordpress设置“固定链接”后,页面404错误的解决方法
Apache解决方案:
/etc/httpd/conf/httpd.config 文件
原因一:Apache中的rewrite模块没有开启,去除这一行前面的#号就可以了
LoadModule rewrite_module modules/mod_rewrite.so
原因二:AllowOverride Not Enabled;服务器可能没打开AllowOverride。如果httpd.config的AllowOverride设置的是None,那.htaccess将被忽略。找到以下2处位置并修改:
<Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/html> # … other directives… AllowOverride All </Directory>
修改完成后,要重启Apache才能生效。
service httpd restart
Nginx解决方案:
设置方式是loction / {}中添加配置:
#加入如下一条命令即可 try_files $uri $uri/ /index.php?$args;
修改完成后重启Nginx服务器生效。
service nginx restart
一、推荐使用迅雷或快车等多线程下载软件下载本站资源。
二、未登录会员无法下载,登录后可获得更多便利功能,若未注册,请先注册。
三、如果服务器暂不能下载请稍后重试!总是不能下载,请点我报错 ,谢谢合作!
四、本站大部分资源是网上搜集或私下交流学习之用,任何涉及商业盈利目的均不得使用,否则产生的一切后果将由您自己承担!本站将不对任何资源负法律责任.如果您发现本站有部分资源侵害了您的权益,请速与我们联系,我们将尽快处理.
五、如有其他问题,请加网站设计交流群(点击这里查看交流群 )进行交流。
六、如需转载本站资源,请注明转载来自并附带链接
七、本站部分资源为加密压缩文件,统一解压密码为:www.aizhanzhe.com
- 1CSS控制文字在Div最底部显示
- 2Thinkphp5如何配置IP+端口访问项目模块
- 3elementUI el-dialog弹框居中
- 4教你如何搭建及优化站点
- 5国内互联网视频行业运营分析
- 6service mysql start出错,mysql不能启动,解决mysql: unrecognized service错误
- 7CSS实现悬浮顶部的Div工具栏
- 8记一次Thinkphp5.1框架mysql数据库崩溃(SQLSTATE [08004] Too many connections)
- 9连接SQL Server数据库提示:Login failed for user 'sa'错误的解决方案
- 10Thinkphp3.2在centos7上设置计划任务的方法