【发布时间】:2022-02-25 09:44:51
【问题描述】:
所以我正在尝试做一些独特的事情,我花了几个小时阅读有关 NGINX 重写以及如何为特定页面创建 CATCH ALL 的内容。
我想做什么:
mysite.com/Subdivision/ 是一个 wordpress 页面。
我希望能够随机生成(TAIL PAGES),默认情况下会转到更高的 wordpress 页面(mysite.com/Subdivision/):
mysite.com/Subdivision/Green-Trails
mysite.com/Subdivision/River-Oaks
mysite.com/Subdivision/Creek-Plantation
然后在我的 /Subdivision/ 页面中,我将编写脚本告诉它如何处理“Green-Trails”和“River-Oaks”以及“Creek-Plantation”
在此之后,目标是添加其他内容,例如
mysite.com/Subdivision/Green-Trails/4-bdr/with-pool/
并且我的 /Subdivision 页面将在 Request-URI 中找到设置“IF 4-bdr”,设置此项。如果在请求 URI 中找到了 with-pool,则设置这个...这将在 PHP sn-p 代码中完成。
只需克服 NGINX 写入障碍。
这是我当前使用 NGINX 的 Centmin 设置:
## BEGIN WORDPRESS MOD ##
index index.php index.html index.htm;
# enforce www (exclude certain subdomains)
if ($host !~* ^(www|subdomain))
{
# rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
}
# enforce NO www if ($host ~* ^www\.(.*)) {
# set $host_without_www $1; rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
#}
# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~ /subdivision/(.*) {
index index.php;
try_files $uri /index.php?q=/subdivision/&$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
## END WORDPRESS MOD ##
如你所见:`
location ~ /subdivision/(.*) {
index index.php;
try_files $uri /index.php?q=/subdivision/&$args;
}
`
我试图告诉 NGINX 将 /Subdivision/ 页面变量提供给 wordpress 并告诉 Wordpress 忽略 URL /Green-Trails/ /River-Oaks/、/Creek-Plantation/ 的其余部分
但这不起作用,有人可以帮助我吗,我错过了哪里?
【问题讨论】: