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