Nginx+php-fpm. static site + Wordpress

344 views Asked by At

Help me please.

I have folder example.com with 2 sites. WordPress Site in WP folder And 100+ static pages in root. I should move WP in root, static pages in "StaticPages" Folder.

i have nginx config:

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;
}

after moving, I want to open my static pages like this.

example.com/mystaticpage.html

I want to open my wordpress pages like this.

example.com/mywppage.html

Without folder name in URL But i don't understand how i can create router for this?

0

There are 0 answers