[英]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.