Nginx + php-fpm。静态网站+ Wordpress

时间:2019-01-21 13:40:51

标签: php wordpress nginx

请帮助我。

我有文件夹 example.com 有2个网站。 WP文件夹中的WordPress网站 根中有100多个静态页面。 我应该将WP移动到“ StaticPages”文件夹中的根静态页面中。

我有nginx配置:

server {
    listen  80;
    server_name example.local www.example.local;
    rewrite ^/(.*) https://www.example.local/$1 permanent;
}

server {
    listen  443 ssl;
    server_name example.local;
    rewrite ^/(.*) https://www.example.local/$1 permanent;
    ssl_certificate /etc/nginx/ssl/example.crt;
    ssl_certificate_key /etc/nginx/ssl/example.key;
}

server {
    listen     443 ssl;
    server_name www.example.local;
    root /home/stanislav/Documents/projects/example.com;
    rewrite_log on;

    index index.html index.php;

    if ($request_uri = /index.html) {
        return 301 $scheme://$host/;
    }

    if ($request_uri = /index.php) {
        return 301 $scheme://$host/;
    }

    location / {
    try_files $uri $uri/ /wp/index.php?$args;
    }

    location ~ \.(php|htm|html|phtml)$  {
    try_files $uri $uri/ /wp/index.php?$args;
    ####
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    ####
    }

    location ~ /\. {
        deny all;
    }

   location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|woff|eot|ttf|pdf|mp4|exe|doc|html|flv|ico|xml|txt|css|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off;
       log_not_found off;
       expires max; # static cache
    }

    location /wp {
    try_files $uri $uri/ /wp/index.php?$args;
    }

    location /lp {
        try_files $uri $uri/ /lp/index.php?$args;
    }

    access_log /var/log/nginx/example.log;
    error_log /var/log/nginx/example.log;

    ssl_certificate /etc/nginx/ssl/example.crt;
    ssl_certificate_key /etc/nginx/ssl/example.key;
}

移动后,我想这样打开我的静态页面。

example.com/mystaticpage.html

我想打开这样的wordpress页面。

example.com/mywppage.html

URL中没有文件夹名称 但是我不明白如何为此创建路由器?

0 个答案:

没有答案
相关问题