zoukankan      html  css  js  c++  java
  • 关于Nginx

    访问 www.a.com 自动跳到 www.b.com(301跳转设置)

    server {
    listen 80;
    server_name www.a.com;
    rewrite ^/(.*)$  http://www.b.com/$1 permanent;
    }

    主目录跳转,子目录不跳转

    server {
    listen 80;
    server_name www.a.us a.us;

    #根目录跳转
    location / {
      rewrite .+ http://www.b.com/ permanent;
    }

    location ~* /.+ {
    #已省略余下通用配置内容
    }
    }

    302跳转

    server {
    listen 80;
    server_name 123.com;
      rewrite ^/(.*) http://456.com/$1 redirect;
      access_log off;
    }

    禁止多个目录
    location ~ ^/(cron|templates)/ {
      deny all;
      break;
    }

    禁止htaccess
    location ~//.ht {
      deny all;
    }

    禁止以/data开头的文件
    可以禁止/data/下多级目录下.log.txt等请求;
    location ~ ^/data {
      deny all;
    }

    只充许固定ip访问网站,并加上密码

    root  /opt/htdocs/www;
    allow 208.97.167.194;
    allow 222.33.1.2;
    allow 231.152.49.4;
    deny all;
    auth_basic "C1G_ADMIN";
    auth_basic_user_file htpasswd;

    多域名转向
    server_name www.c1gstudio.com www.c1gstudio.net;
    index index.html index.htm index.php;
    root /opt/lampp/htdocs;
    if ($host ~ "c1gstudio/.net") {
    rewrite ^(.*) http://www.c1gstudio.com$1 permanent;
    }

    三级域名跳转
    if ($http_host ~* "^(.*)/.i/.c1gstudio/.com$") {
    rewrite ^(.*) http://top.yingjiesheng.com$1;
    break;
    }

  • 相关阅读:
    轮播无缝
    项目开发的注意
    再聊移动端页面的适配
    如何在Vue项目中使用vw实现移动端适配
    移动端适配文章
    vue-cli 配置flexible px2rem-loader安装配置
    vuex复习笔记
    vue-router复习笔记
    vue-cli 笔记
    内置组件 -slot讲解
  • 原文地址:https://www.cnblogs.com/smlile-you-me/p/9835016.html
Copyright © 2011-2022 走看看