.htaccess #www 301跳转到非www RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule...^(.*)$ http://%1/$1 [R=301,L] #单独的http和https执行此操作 RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST}...^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST...%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} !...%{HTTP_HOST}/$1 [R=301,L]
下面对比一下,看第一个配置文件 # 将 RewriteEngine 模式打开 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^m.zcyy.dev...%{QUERY_STRING} [L] # 获取后面跟随的参数 RewriteCond %{HTTP_HOST} ^m.zcyy.dev [NC] RewriteRule ^/(\w+).php$...%{QUERY_STRING} [L] # 获取后面跟随的参数 RewriteCond %{HTTP_HOST} ^m.zcyy.dev [NC] RewriteRule ^(\w+).html$...controller=$1&%{QUERY_STRING} [L] # 获取后面跟随的参数 RewriteCond %{HTTP_HOST} ^m.zcyy.dev [NC] RewriteRule...%{HTTP_HOST} ^m.zcyy.dev [NC] RewriteRule ^(\w+).html$ /wap.php?
修改.htaccess文件 301跳转重定向 RewriteEngine On RewriteCond %{HTTP_HOST}...IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # blog.xbbai.site绑定 到子目录blog RewriteCond %{HTTP_HOST...htaccess代码如下: RewriteEngine On RewriteBase / #只许绑定的域名访问 RewriteCond %{HTTP_HOST...Rewrite [L,QSA] 二级域名使用.htaccess跳转解析到子目录方法二: RewriteEngine On RewriteCond %{HTTP_HOST}...-d RewriteRule ^(.*)$ /blog/$1 RewriteCond %{HTTP_HOST} ^(www.)?blog.xbbai.site$ RewriteRule ^(/)?
.*)$ https://%{HTTP_HOST}/$1 [R,L] 方法二 Bash RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond...%{HTTP_HOST} ^ahaoyw.cn [NC,OR] RewriteCond %{HTTP_HOST} ^www.ahaoyw.cn [NC] RewriteRule ^(.*)$ https...://%{HTTP_HOST}/$1 [R,L] PS:其中ahaoyw.cn和www.ahaoyw.cn为网站域名 如果.htaccess 伪静态规则不生效,需要编辑站点配置文件或者httpd.conf
.*)$ https://%{HTTP_HOST}/$1 [R,L] 或者: RewriteEngine On RewriteCond %{HTTPS} !...IfModule> 站点绑定多个域名,只允许www.talklee.com 跳转 RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{HTTP_HOST...} ^talklee.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.talklee.com [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST... = 'www.talklee.com') { set $redirect_https "${redirect_https}3"; } if ($http_host = 'talklee.com') {...host$1 permanent; } 配置示例: server { listen 80; server_name www.talklee.com; rewrite ^ https://$http_host
"] 后就好了,下面整理下 这两个方法的区别: 简单的来说,HTTP_HOST 是变化的,而 SERVER_NAME 只有一个。...如果你在浏览器用 http://localhost 访问,则 HTTP_HOST 的值为 localhost ,而你用 www.w3h5.com 访问,HTTP_HOST 的值就是 www.w3h5....com ,你用IP地址访问,HTTP_HOST 的值就是 IP,SERVER_NAME 就不会变化,Apache 的httpd.conf 中设置的是什么,显示的就是什么。...通常情况: _SERVER["HTTP_HOST"] 在HTTP/1.1协议规范下,会根据客户端的 HTTP 请求输出信息。...因此在这种情况下,可以理解为:HTTP_HOST = SERVER_NAME : SERVER_PORT 3.
$_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' ....$_SERVER['HTTP_HOST']); 二、限制特定域名访问 也可以只指定某些域名可以访问。...$domain = array("linqingmaoer.cn", "www.linqingmaoer.cn"); if(in_array($_SERVER['HTTP_HOST'], $domain...$_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); }
.*)$ https://%{HTTP_HOST}/$1 [R,L]COPY或者 RewriteEngine OnRewriteCond %{HTTPS} !.../IfModuleCOPY2、站点绑定多个域名只允许 www.XXXX.cn 跳转RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteCond %{HTTP_HOST...} ^XXXX.cn [NC,OR]RewriteCond %{HTTP_HOST} ^www.XXXX.cn [NC]RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1...RewriteEngine onRewriteBase /RewriteCond %{SERVER_PORT} 80RewriteCond %{HTTP_HOST
测试站点数目:3个子站点 子站点程序:一个前端项目+2个php完整项目 .htaccess伪静态规则文件: # 绑定vip.cncat.cn 到子目录vip RewriteCond %{HTTP_HOST...Rewrite [L,QSA] # 可以绑定多个, 只需重复上三行代码并更改一下域名、目录名 就OK了 RewriteCond %{HTTP_HOST} ^vip.cncat.cn$ [NC...] RewriteRule ^$ /vip/ # 绑定video.cncat.cn 到子目录video RewriteCond %{HTTP_HOST} ^video\.cncat\.cn...Rewrite [L,QSA] # 可以绑定多个, 只需重复上三行代码并更改一下域名、目录名 就OK了 RewriteCond %{HTTP_HOST} ^video.cncat.cn$ [... /video/ 相比上次的.htaccess文件中多了一条RewriteCond和一条RewriteRule 解释下新增的RewriteCond和RewriteRule RewriteCond %{HTTP_HOST
demo.local/objectname 相对路径格式 (path-style)-> GET http://s3.demo.local/bucket_name/objectname 而在Nginx日志中可以通过http_host...下面操作中减少了kafka和ES,直接从Filebeat->Logstash进行日志处理 Nginx日志设置 nginx日志配置如下 log_format json '{"scheme":"$scheme","http_host...":"$http_host", "remote_addr":"$remote_addr","server_addr":"$server_addr", "time_local":"[$time_local...add_field => ["bucket_name","%{[http_host][0]}" ] } } } } output { stdout {..."tags" => [ [0] "nginx-access", [1] "beats_input_raw_event" ], "http_host
id=5 //获取域名或主机地址 echo $_SERVER['HTTP_HOST']."...$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo 'http://'.$_SERVER['HTTP_HOST']....$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo 'http://'.$_SERVER['HTTP_HOST'].
if($_SERVER["HTTP_HOST"]=="A域名.com" || $_SERVER["HTTP_HOST"]=="www.A域名.com"){ $db = new Typecho_Db('Mysql...', 'A_'); } else if($_SERVER["HTTP_HOST"]=="B域名.com" || $_SERVER["HTTP_HOST"]=="www.B域名.com"){ $db =
其操作方法是在.htaccess文件中加入以下规则; RewriteEngine On RewriteCond %{HTTP_HOST} !...] 2、重定向www.idcspy.com到idcspy.com 该重定向刚好与上面的相反,在.htaccess文件中加入规则如下; RewriteEngine On RewriteCond %{HTTP_HOST...由于公司的发展可能需要对网站的域名进行更换,此时就需要将老的域名重定向到新的域名中去,在.htaccess文件操作如下; RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST...301] 4、重定向olddomain.com 到 www.newdomain.com 这个只需要在第三种重定向中进行相应的改良就可以 RewriteEngine On RewriteCond %{HTTP_HOST...otherdomain.com/otherfile/other.php 这种是对在更改网站域名的同时,网站目录路径也发生变化的情况下使用,在.htaccess文件中操作如下; RewriteCond %{HTTP_HOST
变量$_SERVER['HTTP_HOST']可以返回Web服务器带端口的主机地址(比如 localhost:8080),$_SERVER['SERVER_NAME']可返回不带端口的主机地址。...php // echo $_SERVER['SERVER_NAME']; echo $_SERVER['HTTP_HOST'].'...str_replace(DIRECTORY_SEPARATOR, '/', $path); // 将DIRECTORY_SEPARATOR都替换为/,便于统一处理 $ServerDomain=$_SERVER['HTTP_HOST...php // echo $_SERVER['SERVER_NAME']; echo $_SERVER['HTTP_HOST'].'...str_replace(DIRECTORY_SEPARATOR, '/', $path); // 将DIRECTORY_SEPARATOR都替换为/,便于统一处理 $ServerDomain=$_SERVER['HTTP_HOST
现在我们以指定daohang.shuyong.net指向/daohang/目录为例修改以上代码: RewriteEngine on RewriteCond %{HTTP_HOST.../index.php [L] RewriteCond %{HTTP_HOST} ^daohang.shuyong.net$ RewriteCond %{REQUEST_URI} !...-d RewriteRule ^(.*)$ /daohang/$1 RewriteCond %{HTTP_HOST} ^daohang.shuyong.net$ RewriteRule ^(/)?
set $nginx_static 'BYPASS For Cookie';}# 判断缓存是否存在if (-f $document_root/wp-content/cache/supercache/$http_host...cache_uri/index-https.html){ set $nginx_static 'HIT';}if (-f $document_root/wp-content/cache/supercache/$http_host...cache_uri/index.html){ set $nginx_static 'HIT';}location /{ try_files /wp-content/cache/supercache/$http_host.../$cache_uri/index-https.html /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/
$_SERVER['HTTP_HOST']....$_SERVER['REQUEST_URI']; $http = $_SERVER['HTTP_HOST']; if(substr($http, 0,3) == 'www'){ $newurl...$_SERVER['HTTP_HOST']....$_SERVER['REQUEST_URI']; $http = $_SERVER['HTTP_HOST']; if(substr($http, 0,1) == 'm'){ $newurl
id=5 //获取域名或主机地址 echo $_SERVER['HTTP_HOST']."...$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo 'http://'.$_SERVER['HTTP_HOST'].
var content_raw ; content_raw = CKEDITOR.instances.editor.getData(); var http_host...= ""; http_host = "http://api.cuobiezi.net"; //http_host = "http...://127.0.0.1:8235"; //-------------------------- var gb_endpoint = http_host
获取代码: 获取当前目录: getcwd(); // /mnt/qa/test dirname(__FILE__); // /mnt/qa/test 获取域名或主机地址 $_SERVER['HTTP_HOST...$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; // http://daxiangtravel.com/qa/test/index.php?...$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.
领取专属 10元无门槛券
手把手带您无忧上云