linux:web:nginx_wordpress
Wordpress控制台設定固定網址
利用wordpress內定好的標籤來設定,本範例是用%postname%文章別名方式。詳細情況請看參考資料第一項。
-
在設定/固定網址,點選自訂結構,如圖
Nginx Rewrite rule設定
接下來需要搭配Nginx rewrite方式才能達到wordpress固定網址。
若不採用Nginx rewrite作法就會產生以下錯誤。

Nginx Rewrite 設定,當client端 $request_filename 不存在,就將全部檔案導到 wordpress 根目錄下的 index.php
server {
listen 80;
server_name ~^(www\.)?test202.com;
root /var/www/html/test2;
#charset koi8-r;
access_log /var/log/nginx/test-access.log main;
error_log /var/log/nginx/test-error.log;
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
#error_page 404 /404.html;
if (!-f $request_filename) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
#error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
參考資料
linux/web/nginx_wordpress.txt · 上一次變更: 2014/06/12 02:40 由 ali88