[英]Rewrite custom wordpress parameters
我嘗試用參數重寫wordpress網址,例如:
來自: http : //www.url.com/person/?fname=billn&lname=gates
到: http : //www.url.com/person/jason/gates/
來自: http : //www.url.com/company/?name=microsoft&country=usa
到: http : //www.url.com/company/microsoft/usa/
其中person和company是wordpress頁面,Fname,lname,name和country是自定義$ _get參數。
我嘗試了一些操作(無結果),例如:
rewrite ^/page/bill/gates/(.*)$ /index.php?p=6&fname=$1&lname=$2 last;
我目前為Nginx使用默認的Wordpress配置:
server {
listen 80;
listen [::]:80
root /var/www;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
}
好吧,我認為您可以嘗試將args附加到wordpress args上,如下所示
location ^/page/([^/]+)/([^/]+)/?$ {
try_files /index.php?$args&name=$1&type=$2 =404;
}
我將這樣的內容用於我的一個網站,以對所有鏈接進行操作。
location / {
if (!-e $request_filename){
rewrite ^/fonts/(.+)$ /system/application/fonts/$1 last;
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
}
因此,僅用於頁面..也許您可以嘗試:
location / {
if (!-e $request_filename){
rewrite ^/page/(.*)$ /index.php?/$1 last;
break;
}
}
編輯:來自Nginx的PHP重寫規則。http://www.farinspace.com/wordpress-nginx-rewrite-rules/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.