wordpress基于nginx和apache伪静态配置

2020-06-17 589 0

NGINX版本

配置参考docker版:bitnami/wordpress-nginx

server {
  listen 0.0.0.0:88;
  server_name localhost;

  root /usr/share/nginx/html;
  index index.php;

  #通用匹配,优先级最低,任何未匹配到其它location的请求都会匹配到,相当于switch中的default
  location / {
    #尝试$uri存在直接返回,再尝试$uri/存在则301重定向,否则执行最后段内部转发(所有其它匹配不到的,都会走转发index.php)
    try_files $uri $uri/ /index.php?q=$uri&$args;
    #try_files $uri $uri/ =404;
    add_header t_try "try";
    add_header uri $uri;
    add_header ruri $request_uri;
  }

  #如果文件不存在,则执行内部转发
  if (!-e $request_filename)
  {
    rewrite ^/(.+)$ /index.php?q=$1 last;
  }

  #所有.php请求
  location ~ \.php$ {
    fastcgi_pass 172.17.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    add_header t_php "php";
    add_header uri $uri;
    add_header ruri $request_uri;

  }
}

apache 版本

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

相关文章

线上PostgreSQL锁表故障分析
PostgreSQL创建外部表场景及使用
vim常用命令
navicat15 for linux桌面的破解激活
快速实现通用的办公文档在线预览方案
自建流媒体服务,快速打造自己的短视频点播平台

发布评论