网站搬家 旧站智能跳转至新站
第一种方法 添加一个index.html php 智能404跳转代码,适合换域名没改变目录的网站 适合于换域名,但是目录没有改变的网站.也可以用做301定向.转自于落伍 代码如下:复制代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>404</title> <meta http-equiv='refresh' content='5; url=http://www.jb51.net<?=$_SERVER[REQUEST_URI]?>'> </head> <body> 本站起用新域名访问 你目前访问的页面是http://www.jb51.cn<?=$_SERVER['REQUEST_URI']?> 系统为你重新定向到新站相应的页面http://www.jb51.net<?=$_SERVER['REQUEST_URI']?> 或等待5秒后,系统自动跳转到新站相应的页面 </body> </html> 第二种方法 Apache主机修改.htaccess实现跳转 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC] RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ...