米狗

  • kubernets
  • docker
  • AWS
  • linux
  • nginx
Kratos
  1. 首页
  2. 中间件
  3. nginx
  4. 正文

wordpress配置中英文站点

2022年8月25日 722点热度 0人点赞 0条评论

业务实际需要,需要使用wordpress配置公司中英文站点,nginx、php、wordpress安装见站内其他文章,nginx配置如下:

    ############www.demo-cloud.com################################3

    upstream demo {
       server 127.0.0.1:9000;
    }
        server {
        listen        80;
        server_name   www.demo-cloud.com;
        rewrite            ^(.*)$  https://$host$1 permanent;
        }
        server {
        listen                                       443 ssl;
        server_name                                  www.demo-cloud.com;
        ssl_certificate                              demo.pem;
        ssl_certificate_key                          demo.key;
        ssl_session_timeout                          5m;
        ssl_protocols                                TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers                                  'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES';
        ssl_prefer_server_ciphers                    on;
        index index.php index.html index.htm default.php default.htm default.htm;
        root /app/demo;
        access_log logs/www.demo-cloud.com.log log_json;

        allow 58.33.3.246/32;
        allow 101.52.254.25/32;
        deny all;

    ####设置访问主页重定向到中文网站
        location / {
            if ($host = 'www.demo-cloud.com') {
                rewrite ^/(.*)$ http://www.demo-cloud.com/cn permanent;
            }
        }

    ####设置英文网站对应的目录

        location /en {
            if (-f $request_filename/index.html){
                    rewrite (.*) $1/index.html break;
            }
            if (-f $request_filename/index.php){
                    rewrite (.*) $1/index.php;
            }
        if (!-f $request_filename){
                    rewrite (.*) /en/index.php;
            }
        }
    ####设置中文网站对应的目录

        location /cn {
            if (-f $request_filename/index.html){
                    rewrite (.*) $1/index.html break;
            }
            if (-f $request_filename/index.php){

                    rewrite (.*) $1/index.php last;
            }
        if (!-f $request_filename){
                    rewrite (.*) /zh/index.php last;
            }
        }
########设置php转发参数
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass demo;
            fastcgi_index   index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

        if ($request_method !~ ^(GET|HEAD|POST)$ ) {
            return 501;
        }
        proxy_intercept_errors on;
        error_page  500 502 503 504 /50x.html;
        error_page 404 /404.html;
        location  ~ /(404|50x).html {
            root html/errorHtml;
        }
        location ~ .*/errorHtml/ {
            rewrite ^/.*/(errorHtml/.*)$ /$1 permanent;
            access_log off;
        }
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

     }

附上nginx配置文件,供大家参考。

标签: wordpress配置中英文站点
最后更新:2022年8月28日

duhongjun

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

归档

  • 2024 年 10 月
  • 2024 年 4 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2024 年 1 月
  • 2023 年 11 月
  • 2023 年 4 月
  • 2023 年 2 月
  • 2023 年 1 月
  • 2022 年 11 月
  • 2022 年 10 月
  • 2022 年 9 月
  • 2022 年 8 月
  • 2021 年 12 月
  • 2021 年 11 月
  • 2021 年 8 月
  • 2021 年 7 月
  • 2021 年 6 月
  • 2021 年 2 月
  • 2020 年 1 月
  • 2019 年 12 月
  • 2019 年 11 月
  • 2019 年 10 月
  • 2019 年 9 月
  • 2019 年 8 月

分类目录

  • AWS
  • docker
  • elasticsearch
  • Jenkins
  • kubernets
  • linux
  • mysql
  • nginx
  • Oracle
  • php
  • redis
  • zabbix
  • 个人
  • 中间件
  • 公有云
  • 大数据
  • 安全工具
  • 微软
  • 操作系统
  • 数据库
  • 未分类
  • 监控
  • 科技
  • 网络技术
  • 资讯
  • 阿里云

COPYRIGHT © 2024 米狗. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

沪ICP备2021019346号-1