這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
linux:web:nginx_wordpress [2014/06/12 01:54] ali88 |
linux:web:nginx_wordpress [2014/06/12 02:40] (目前版本) ali88 |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | ======Wordpress控制台設定固定網址====== | ||
+ | - 利用wordpress內定好的標籤來設定,本範例是用**%postname%**文章別名方式。詳細情況請看參考資料第一項。 | ||
+ | - 用**%postname%**,呈現效果為http://yourDomain/TEST/,http://yourDomain/TEST2/ | ||
+ | - 在設定/固定網址,點選自訂結構,如圖 | ||
+ | {{:linux:web:wordpress_固定網址.png|}} | ||
+ | ======Nginx Rewrite rule設定====== | ||
+ | - 接下來需要搭配Nginx rewrite方式才能達到wordpress固定網址。 | ||
+ | - 若不採用Nginx rewrite作法就會產生以下錯誤。{{:linux:web:no_nginx_error_wordpress.png|}} | ||
+ | - Nginx Rewrite 設定,當client端 $request_filename 不存在,就將全部檔案導到 wordpress 根目錄下的 index.php<code> | ||
+ | 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; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
======參考資料====== | ======參考資料====== | ||
* [[http://codex.wordpress.org/zh-tw:%E4%BD%BF%E7%94%A8%E5%9B%BA%E5%AE%9A%E9%80%A3%E7%B5%90|zh-tw:使用固定連結_WordPress官網]] | * [[http://codex.wordpress.org/zh-tw:%E4%BD%BF%E7%94%A8%E5%9B%BA%E5%AE%9A%E9%80%A3%E7%B5%90|zh-tw:使用固定連結_WordPress官網]] | ||
+ | * [[http://www.farinspace.com/wordpress-nginx-rewrite-rules/|WordPress NGINX Rewrite Rules]] | ||
+ | * [[http://www.ccvita.com/336.html|Nginx下WordPress的Rewrite]] |