在WordPress托管网站

时间:2016-12-27 20:11:49

标签: php wordpress nginx

我刚刚推出了一个WordPress网站,其中有一个表单,允许用户选择他们想要购买的东西。我们正在实施第三方购物车服务,该服务要求网址采用非常特定的格式。我想检索POSTed变量,然后向第三方购物车发出重定向(基本上是GET)。我打算创建一个只做那个的buy.php文件 - 检索POST变量并创建url。

问题是我不知道如何公开buy.php页面。我一直被转到404.html页面。

我想我会在所有其他位置之前创建一个新位置,但是服务器日志抱怨无法找到该文件。一旦我解决了这个问题,就没有触及该文件,但请求是由404页面处理的。

服务器正在运行Nginx。配置如下:

server {

  access_log off;
  error_log  /var/log/site-name.com_error_log;
  root /var/www/vhosts/site-name.com/httpdocs;

  listen    80;
  listen    443 ssl;
  ssl_certificate /XXX.pem;
  ssl_certificate_key /XXX-cert.key;

  # server_name   www.site-name.com ;
  server_name   site-name.com ;

  # i can't get this /buy to work
  location /buy/ {
    #  what do I put here to be used in a form Action
  }

  location / {
    root   /var/www/vhosts/site-name.com/httpdocs;
    index  index.html index.php index.htm;
        try_files $uri $uri/ /index.php?$args;
  }

   location @handler {
    rewrite / /index.php;
  }

  location ~ .php/ {
    rewrite ^(.*.php)/ $1 last;
  }

  location ~ .php$ {
    try_files $uri /index.php;
    expires off;
    fastcgi_pass 127.0.0.1:8080;
    fastcgi_buffers 256 4k;
    fastcgi_buffer_size 32k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_read_timeout 3600s;


#      fastcgi_param HTTPS $fastcgi_https;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param MAGE_RUN_CODE default;
    fastcgi_param MAGE_RUN_TYPE store;

    include fastcgi_params;
 }

# WordPress single site rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule

   # Add trailing slash to */wp-admin requests.
  rewrite /wp-admin$ $scheme://$host$uri/ permanent;

  location ~*  \.(jpg|jpeg|png|gif|ico|css|js|eot|woff|woff2|ttf)$ {
        expires 365d; access_log off; log_not_found off;
  }
}

1 个答案:

答案 0 :(得分:0)

好的,我明白了。我只需要为该部分重写一个语句,另一个需要测试它:

location /buy {
     rewrite / /wp-content/themes/uncode-child/buy/index.php;
}

location /test {
     rewrite / /wp-content/themes/uncode-child/buy/test.html;
}