php - Nginx+php-fpm。静态网站 + WordPress
问题描述
请帮帮我。
我有包含 2 个站点的文件夹example.com 。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 中没有文件夹名称但我不明白如何为此创建路由器?
解决方案
推荐阅读
- php - SQL 语句 where 如果下一个值与当前值相同则跳过该值
- bash - 为什么使用两个变量时 sed 失败?
- django-rest-framework - 如何对二进制资源进行内容协商
- java - 安装了 Elasticsearch 5.5 服务启动失败
- react-native - 我们如何将 React Native App 连接到 octobercms 后端?
- c++ - 如果在函数之外定义,则在 ofstream::open() 上出现段错误
- node.js - 使用 deletemany 清空 MongoDB(通过 Azure Cosmos Db)共享集合
- controller - FluidTYPO3 流体页面 - 未找到自定义页面控制器
- android - Android App Intent Filter 有时不起作用
- python - 超时和异常函数卡住了