PHP实现301跳转的方法:$theHost = $_SERVER[‘HTTP_HOST‘];
$theUrl = isset($_SERVER[‘REQUEST_URI‘])? $_SERVER[‘REQUEST_URI‘]:‘‘;
$theUrl = strtolower($theUrl);
if($theUrl == ‘/index.php‘)
{$theUrl = ‘‘;
}
if($theHost != ‘www.test.com‘)
{header(‘HTTP/1.1 301 Moved Permanently‘);header(‘Location:http://www.test.com‘.$the_url);
}将此代码放在*.php首行,或者放置在config.php中。原文:http...
原文:http://www.cnblogs.com/aivnfjgj/p/6551008.html
/*** get_redirect_url()* Gets the address that the provided URL redirects to,* or FALSE if theres no redirect. ** @param string $url* @return string*/
function get_redirect_url($url){$redirect_url = null; $url_parts = @parse_url($url);if (!$url_parts) return false;if (!isset($url_parts[host])) return false; //cant process relative URLsif (!isset($url_parts[path])) $url_parts[path] = /;$sock = fsoc...
代码如下:/** * get_redirect_url() * Gets the address that the provided URL redirects to, * or FALSE if there's no redirect. * * @param string $url * @return string */function get_redirect_url($url){ $redirect_url = null; $url_parts = @parse_url($url); if (!$url_parts) return false; if (!isset($url_parts['host'])) return false; //can't process relative URLs if (!isset($url_parts['p...
301跳转就是告诉访问者页面己经永远到了新的页面了,在php中使用301跳转我们利用header()函数发送301状态代码告诉浏览器,然后再实现页面跳转即可。PHP纯代码跳转代码如下header("Location:http://www.bKjia.c0m/");?>但是这种返回的状态码是302
如果要实现301跳转的话,需要在之前设置下状态码代码如下header( "HTTP/1.1 301 Moved Permanently" ) ;header("Location:http://www.bKjia.c0m/");?>更简单的PHP跳转301代码代码如下$u...
PHP 301跳转的小代码代码如下: $the_host = $_SERVER['HTTP_HOST']; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if($the_host !== 'www.gxlcms.com') { //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.gxlcms.com' . $_SERVER['PHP_SELF'] . $request_uri); }?>http://www.bkjia.com/PHPjc/825209...
比如 http://127.0.0.1:3517/caskesh/data/index.php?i1=23&i2=80 这样的一个地址 如何让它能跳转到 www.baidu.com/7/index.asp?i1=23&i2=80 或者www.baidu.com/7/?i1=23&i2=80 这个页面呢? i1和i2的参数都是可以修改的 并且跳转后的都是跟跳转前的参数一样。 各位大牛出来指点指点 回复讨论(解决方案) $i1=$GET[i1];$i2=$GET[i2];Header("HTTP/1.1 301 Moved Permanently");Header("Location: www.baidu....
用301跳转把不带www的域名跳转到带www的域名上 appserv服务器, 把这段代码写入.htaccess文件中,服务器会报错 RewriteEngine OnRewriteCond %{HTTP_HOST} ^xxx.net [NC]RewriteRule ^(.*)$ http://www.xxx.net/$1 [L,R=301] 报这个错, 500: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. 求解是咋回事呢 回复...
求助 更换域名301跳转问题假设老域名: a.com ,新域名: b.com 请教如何配置.htaccess,将原域名所有URL 301跳转到新域名,包括二级域名如:www.a.com -> www.b.com a.com -> www.b.com shop.a.com -> shop.b.com photo.a.com -> photo.b.com...................... 等等我在 .htaccess添加了以下规则,会把所有URL转向到www.b.com ,无法满足要求RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENA...
php程序网站整站实现301跳转的方法先看跳转代码$dest_host=”www.99downs.com”; //申明一个变量$dest_host存放要跳转的网址$url = $_SERVER['REQUEST_URI']; //申明一个变量$url存放获取当前网站的主机地址及网站url$http = (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=’off’)?’https://’:'http://’; //申明变量$http存放协议//$port = $_SERVER['SERVER_PORT']==’80′?”:’:'$_SERVER['SERVER_PORT']; ...
去掉斜杠的301跳转怎么写?我用的是PHP虚拟主机,怎么把xxxx.com/abc/ 做301跳转到xxxx.com/abc (其实就是去掉那个斜杠)现在httpd.ini文件如下:[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32RewriteCond Host: ^www\.xxxx\.com$
RewriteRule (.*) http\://xxxx\.com$1 [I,RP]------解决方案--------------------RewriteRule (.*)/ http\://xxxx\.com$1 [I,RP]
RewriteRule (.*) http\://xxxx\.com$1 [I,...
301跳转出错用301跳转把不带www的域名跳转到带www的域名上appserv服务器,把这段代码写入.htaccess文件中,服务器会报错RewriteEngine OnRewriteCond %{HTTP_HOST} ^xxx.net [NC]RewriteRule ^(.*)$ http://www.xxx.net/$1 [L,R=301]报这个错,500:Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.求解是咋回事呢------解决思路-------------------...
PHP 301跳转的小代码代码如下: $the_host = $_SERVER['HTTP_HOST']; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if($the_host !== 'www.php.com') { //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.php.com' . $_SERVER['PHP_SELF'] . $request_uri); }?>
代码如下:/** * get_redirect_url() * Gets the address that the provided URL redirects to, * or FALSE if there's no redirect. * * @param string $url * @return string */function get_redirect_url($url){ $redirect_url = null; $url_parts = @parse_url($url); if (!$url_parts) return false; if (!isset($url_parts['host'])) return false; //can't process relative URLs if (!isset($url_parts['p...
PHP 301跳转的小代码代码如下: $the_host = $_SERVER['HTTP_HOST']; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if($the_host !== 'www.bitsCN.com') { //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.bitsCN.com' . $_SERVER['PHP_SELF'] . $request_uri); }?>