【阿里云能设置域名吗】教程文章相关的互联网学习教程文章

PHP实现通过URL提取根域名_php技巧

PHP根据URL提取根域名,个人工作中用到,由于网络上很多代码都不能得到正确结果就自己写了一个,欢迎大家使用并提出其中的bug. <?php #使用示例 echo getBaseDomain(http://blog.jp.goo.ne.jp/index.php)->domain;echo "\n"; echo getBaseDomain(http://51.ca/index.php)->domain;echo "\n"; echo getBaseDomain(http://blog.ab.cc.win.aisa.hk/index.php)->domain;echo "\n";function getBaseDomain($url=){if(!$url){return $ur...

PHP设置多域名允许跨域访问【代码】

针对 PHP 语言设置多域名允许跨域访问服务器变量:服务器变量存储在 $_SERVER 数组中,在这个数组中有一个特殊的键值:HTTP_ORIGIN。这个键只在跨域的时候才会存在值,同源时为空字符串响应头设置允许某域名访问:access-control-allow-originheader 函数可以设置允许某域名跨域访问,形式为 header(access_control_allow_origin:*)。贴代码:$allow_origin = array(a.baidu.com,b.baidu.com, ); //跨域访问的时候才会存在此字段 $...

同一空间绑定多个域名而实现访问不同页面的PHP代码

<?php switch ($_SERVER["HTTP_HOST"]) { case "www1.aspcn.net": header("location:index1.htm"); break; case "www2.aspcn.net": header("location:index2.htm"); break; case "www3.aspcn.net": header("location:index3.htm"); ...... 继续添加 ...... break; } ?>

PHP获取网站域名和地址的代码

代码如下:<? function PMA_getenv($var_name) { if (isset($_SERVER[$var_name])) { return $_SERVER[$var_name]; } elseif (isset($_ENV[$var_name])) { return $_ENV[$var_name]; } elseif (getenv($var_name)) { return getenv($var_name); } elseif (function_exists(apache_getenv) && apache_getenv($var_name, true)) { return apache_getenv($var_name, true); } return ; } if (empty($HTTP_HOST)) { if (PMA_getenv(HTTP...

PHP实现域名whois查询的代码(数据源万网、新网)

万网 whois(使用的接口为万网提供合法接口) 代码如下:function whois_hichina($domain) { preg_match("|<pre>(.+?)</pre>|is", @file_get_contents(http://whois.hichina.com/cgi-bin/whois?domain=.$domain.), $whois); $whois[0] = str_replace(友情提示:按注册局要求,过期域名可能会处于注册商自动续费期阶段,您在此查询所看到的域名到期日仅供参考<br />请您<a href="http://www.net.cn/has_client/userlogon/user_logon1....

php 智能404跳转代码,适合换域名没改变目录的网站

代码如下:<!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=//www.gxlcms.com<?=$_SERVER[REQUEST_URI]?>> </head> <body> 本站起用新域名访问 你目前访问...

php短域名转换为实际域名函数

代码如下:$url = "http://sinaurl.cn/hbdsU5"; echo unshorten($url); function unshorten($url) { $url = trim($url); $headers = get_headers($url); $location = $url; $short = false; foreach($headers as $head) { if($head=="HTTP/1.1 302 Found") $short = true; if($short && startwith($head,"Location: ")) { $location = substr($head,10); } } return $location; } function startwith($Haystack, $Needle){ return s...

php中取得URL的根域名的代码

代码如下:<?php /** * 取得根域名 * * @author lonely * @create 2011-3-11 * @version 0.1 * @lastupdate lonely * @package Sl */ class Sl_RootDomain{ private static $self; private $domain=null; private $host=null; private $state_domain; private $top_domain; /** * 取得域名分析实例 * Enter description here ... */ public static function instace(){ if(!self::$self) self::$self=new self(); return self::$sel...

PHP获取网址的顶级域名函数代码

PHP获取网址的顶级域名函数 目前国际顶级域名有:com|edu|gov|int|mil|net|org|biz|info|pro|name|museum|coop|aero|xxx|idv|mobi|cc|me 地域型域名比较多,应该是每个国家地区都会有吧,有心可以去收集,不过据我了解这个域名都是2个字母构成的,它可以单独使用也可以喝国际顶级域名结合使用地域型域名如: cn 中国 tw 台湾 hk 香港 域名例子: jb51.cn baidu.com jb51.com.cn 以jb51.dom.cn为例:phpwind(自定义部分).com(国际...

域名和cookie问题(域名后缀)【图】

域名和cookie 偶然想到一个问题:www.g.cn能把cookie设置为.g.cn,那么www.com.cn能设置把cookie设置为.com.cn吗? 试验结果:不能。因为浏览器知道www.com.cn的后缀是.com.cn而不是.cn,所以禁止设置cookie。 因为浏览器内置了域名后缀列表。todo:如果以后出现新的后缀,而老浏览器没法更新列表,岂不是会允许设置cookie? extension后缀 一级域名 二级域名www.g.cn .cn g.cn *.g.cnwww.com.cn .com.cn www.com.cn *.www.com.cnw...

解析PHP获取当前网址及域名的实现代码

代码如下:<?//获取当前的域名:echo $_SERVER['SERVER_NAME'];//获取来源网址,即点击来到本页的上页网址echo $_SERVER["HTTP_REFERER"];$_SERVER['REQUEST_URI'];//获取当前域名的后缀$_SERVER['HTTP_HOST'];//获取当前域名dirname(__FILE__);//获取当前文件的物理路径dirname(__FILE__)."/../";//获取当前文件的上一级物理路径?>

利用PHP实现短域名互转

代码如下:/** * 短域名生成&解析类 */ class Build_URL { private $mem; private $base_url = 'http://xxx.com/'; public function __construct() { $mem_conf = array( array( 'host' => '192.168.10.90', 'port' => '11116' ), array( 'host' => '192.168.10.90'...

PHP JS Ip地址及域名格式检测代码

PHP IP地址格式检测函数代码如下:function checkIp($ip){ $ip = str_replace(" ", "", $ip); $ip = strtolower($ip); $ip= str_replace("http://", "", $ip); $ip= str_replace("https://", "", $ip); if(preg_match(/[A-Za-z_-]/,$ip)){ if(preg_match(/^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|(io)|(tw)|(c...

php获取域名的google收录示例

代码如下:function get_index($domain){ $url="http://www.google.com/search?source=hp&biw=1440&bih=762&q=site%3A$domain&aq=f&aqi=g10&aql=&oq="; $html=file_get_contents($url); preg_match(/<div id=resultStats>[\S\s].*<nobr>/Ui, $html,$index); for($i=0;$i<=strlen($index[0]);$i++){ if(is_numeric($index[0][$i])){ $count.=$index[0][$i]; } } return $count; }

php采用curl访问域名返回405 method not allowed提示的解决方法

/*** http测试* 注:PHP版本5.2以上才支持CURL_IPRESOLVE_V4* @param $url 网站域名* @param $type 网站访问协议* @param $ipresolve 解析方式*/ public function web_http($url,$type,$ipresolve) {//设置Header头$header[] = "Accept: application/json";$header[] = "Accept-Encoding: gzip";$httptype = function_exists(curl_init);if (!$httptype) {$html = file_get_contents($url);} else {$ch = curl_init();curl_setopt(...