一、配置

#vi /usr/local/nginx/conf/vhost/test.com.conf

写入:

server

{

listen 80;

server_name test.com test1.com test2.com;

//是server_name后面可以跟多个域名

index index.html index.htm index.php;

root /data/nginx/test.com;

if ($host != 'test.com' ){

rewrite ^(.*)$ http://test.com/$1 permanent;

//permanent为永久重定向,相当于httpd的R=301

}

}

#/usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfu

二、检验测试

#curl -x127.0.0.1:80 test1.com/123.txt -I

状态码301

检验成功

LNMP配置——Nginx配置 ——域名重定向的更多相关文章

  1. lnmp之Nginx配置https加密访问

    配置lnmp之Nginx网站支持https加密访问 注: 1. 这里拿购买的(pxsnx.pxjy.com)证书来做样例 证书文件共有三个---> (pxsnxg.pxjy.com_ca.crt ...

  2. lnmp下 nginx 配置虚拟主机

    <一.参考> 这里以配置2个站点(2个域名)为例,n 个站点可以相应增加调整,假设: IP地址: 202.55.1.100 域名1 example1.com 放在 /www/example ...

  3. 免费SSL-HTTS 申请与配置 NGINX配置

    Let's Encrypt是很火的一个免费SSL证书发行项目,自动化发行证书,证书有90天的有效期.适合个人使用或者临时使用,不用再忍受自签发证书不受浏览器信赖的提示.Let's Encrypt已经发 ...

  4. LNMP配置——Nginx配置 ——Nginx防盗链

    一.配置 #vi /usr/local/nginx/conf/vhost/test.com.conf 写入: server { listen 80; server_name test.com test ...

  5. LNMP配置——Nginx配置 —— 默认虚拟主机

    一.配置 首先修改配置文件 #vi /usr/local/nginx/conf/nginx.conf 在最后一个结束符号}前加一行配置: include vhost/*.conf; 意思就是/usr/ ...

  6. 配置nginx多域名虚拟主机

    1.先做域名映射,由于我们使用的是阿里云域名. 登录阿里云控制台-->域名与网站(万网)-->域名-->选择一个域名-->域名解析-->添加记录 配置静态资源下载转发: ...

  7. mac 配置nginx 虚拟域名(转载)

    我是通过homebrew 安装nginx 的,所以安装目录是默认的,之前多个server都是放在默认安装目录下的nginx.conf里的,但是这样不太好,就是会导致nginx.conf 越来越长,而且 ...

  8. LNMP配置——Nginx配置 —— Nginx解析PHP

    一.配置 #vi /usr/local/nginx/conf/vhost/test.com.conf 写入: server { listen 80; server_name test.com test ...

  9. LNMP配置——Nginx配置 —— 配置静态文件不记录日志并添加过期时间

    一.配置 #vi /usr/local/nginx/conf/vhost/test.com.conf 写入; server { listen 80; server_name test.com test ...

随机推荐

  1. java实现定时任务解决方案

    在线corn表达式 1. 总结常见的实现定时任务的几种方法 thread实现 [原理:通过创建一个线程,让他在while循环里面一直运行,用sleep() 方法让其休眠从而达到定时任务的效果.] Ti ...

  2. ThreadLocal使用全解

    一.何为ThreadLocal 1.ThreadLocal的含义 ThreadLocal,即线程变量,是一个以ThreadLocal对象为键,任意对象为值的存储结构.这个结构被附带在线程上,也就是说一 ...

  3. Rsyncd 同步服务

    目录 数据备份的策略 三种数据备份 三种数据备份的比较(转载) 不同数据备份类型组合说明(转载) Rsyncd 服务传输模式(remote synchronizetion deamon) 本地传输模式 ...

  4. codeforces 1077D Cutting Out 【二分】

    题目:戳这里 题意:给n个数的数组,要求找k个数满足,这k个数在数组中出现的次数最多. 解题思路:k个数每个数出现次数都要最大化,可以想到二分下限,主要是正确的二分不好写. 附ac代码: 1 #inc ...

  5. Spring配置声明式事务

    Spring的事务有两种配置,一种是编程式,另一种是声明式,这里我们配置的是声明式事务 <?xml version="1.0" encoding="UTF-8&qu ...

  6. CSS3 弹性盒子(Flex Box)

    1 CSS3 弹性盒子(Flex Box) 1 http://caniuse.com/#search=flex%20box https://www.w3.org/TR/css-flexbox-1/ C ...

  7. React Creating Elements All In One

    React Creating Elements All In One https://reactjs.org/docs/react-api.html#creating-react-elements h ...

  8. SwiftUI & Compose View

    SwiftUI & Compose View OK // // ContentView.swift // Landmarks // // Created by 夏凌晨 on 2020/10/2 ...

  9. vue & template & v-else & v-for bug

    vue & template & v-else & v-for bug nested table bug https://codepen.io/xgqfrms/pen/wvaG ...

  10. TS & error

    TS & error Function implementation is missing or not immediately following the declaration.ts ht ...