Notice (8): file_put_contents(): Write of 270 bytes failed with errno=28 No space left on device [CORE/src/Log/Engine/FileLog.php, line 140]

Notice: file_put_contents() [function.file-put-contents]: Write of 1108 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 284 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 2558 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5437 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3151 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 4079 of 4085 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2757 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 822 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3150 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2073 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2097 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2073 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2097 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
apache+php完美解决301重定向的两种方法 - 站长搜索
首页 > 资讯列表 > 编程/数据库 >>

apache+php完美解决301重定向的两种方法

Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]
Notice: file_put_contents() [function.file-put-contents]: Write of 2421 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2445 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
">
Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2421 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2445 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
2014-11-27 21:30:26 转载来源: 网络整理/侵权必删

本文为大家讲解的是apache和php实现301重定向的两种方法,感兴趣的同学参考下。 301重定向真是个好方法啊

本文为大家讲解的是apache和php实现301重定向两种方法,感兴趣的同学参考下。

301重定向真是个好方法啊。前一篇文章Gevin也说过,本博客不幸被换域名了。域名一换,以前辛苦做博客的成果也就报废了,网上的相关链接也打不开了,搜索引擎的收录也杯具了

301重定向可促进搜索引擎优化效果
从搜索引擎优化角度出发,301重定向是网址重定向最为可行的一种办法。当网站的域名发生变更后,搜索引擎只对新网址进行索引,同时又会把旧地址下原有的外部链接如数转移到新地址下,从而不会让网站的排名因为网址变更而收到丝毫影响。同样,在使用301永久性重定向命令让多个域名指向网站主域时,亦不会对网站的排名产生任何负面影响。

关于301重定向的更多内容,大家不妨Google一下。本文只介绍实现方法啦!
301重定向的实现,我以前也写过一篇相关的文章,但这篇文章的解决方法比较简单,只能实现主页的跳转,本文介绍的这两种方法,可以完美实现301重定向。

方法1:修改.htaccess文件
代码如下:


<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} blog.iflyhigher.tk$ [NC]
RewriteRule ^(.*)$ http://blog.xxx.net/$1 [R=301,L]
RewriteCond %{HTTP_HOST} iflyhigher.tk$ [NC]
RewriteRule ^(.*)$ http://xxx.net/$1 [R=301,L]
RewriteCond %{HTTP_HOST} moiya.tk$ [NC]
RewriteRule ^(.*)$ http://xxx.net/$1 [R=301,L]
</ifmodule>


本博需要对三个域名进行重定向,所以写的比较多,关键代码就是2句话


RewriteCond %{HTTP_HOST} blog.iflyhigher.tk$ [NC]
RewriteRule ^(.*)$ http://blog.xxx.net/$1 [R=301,L]


红色的域名是需要被重定向的旧域名,绿色的是现在网站的域名。


方法2:使用PHP的重定向代码
新建一个index.php文件,然后参考下面代码按自己的重定向要求做简单修改:

 


<?php
$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
switch ($the_host)
{
case "www.iflyhigher.tk":
case "iflyhigher.tk":
$location = "Location: http://xxx.net" . $request_uri;
break;
case "blog.iflyhigher.tk":
$location = "Location: http://blog.xxx.net" . $request_uri;
break;
case "www.moiya.tk":
case "moiya.tk":
$location = "Location: http://xxxx.net";
break;
default:
$location = "Location: http://xxx.net";
break;
}
header('HTTP/1.1 301 Moved Permanently');
header($location);
exit();
?>


如果只要对一个域名进行重定向,可以把代码简化成下面的形式:

 


<?php
$the_host = $_SERVER['HTTP_HOST'];//取得进入所输入的域名
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';//判断后面的请求部分
if($the_host !== 'xxx.net')//xxx.net是我现在的域名
{
header('HTTP/1.1 301 Moved Permanently');//发出301头部
header('Location: http://xxx.net'.$request_uri);//跳转到我的新域名地址
exit();
}
?>


注意,最后的exit()函数是一定要写的,我最初就没有写,结果只能重定向首页,像http://blog.iflyhigher.tk/guestbook这样的网页,就无法进行重定向。
最后,关于重定向的一些细节
由于要对三个域名进行重定向,重定向前,我首先将这三个域名作为Addon Domain绑定到我的服务器上去,并让这三个域名指向同一个文件夹,这样,只要修改这一个文件夹中的.htaccess文件或者index.php文件就可以了。如果没有.htaccess文件或者index.php文件,新建一个即可。
希望本文对需要进行301重定向的朋友有帮助。
转载请表明出处: Gevin的博客

 


标签: apache+php 完美 解决 重定向 两种 方法


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2025 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持