Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WordPress托管的站点上公开php文件_Php_Wordpress_Nginx - Fatal编程技术网

在WordPress托管的站点上公开php文件

在WordPress托管的站点上公开php文件,php,wordpress,nginx,Php,Wordpress,Nginx,我刚刚启动了一个WordPress网站,它有一个表单,允许用户选择他们想买的东西。我们正在实施一项第三方购物车服务,该服务要求URL采用非常特定的格式。我想检索发布的变量,然后向这个第三方购物车发出重定向(基本上是GET)。我只是想创建一个buy.php文件,它可以检索POST变量并创建url 问题是我不知道如何公开buy.php页面。我一直被发送到404.html页面 我想我会先创建一个新位置,但服务器日志抱怨找不到文件。一旦我解决了这个问题,文件就不会被触动,但请求是由404页面处理的 服务

我刚刚启动了一个WordPress网站,它有一个表单,允许用户选择他们想买的东西。我们正在实施一项第三方购物车服务,该服务要求URL采用非常特定的格式。我想检索发布的变量,然后向这个第三方购物车发出重定向(基本上是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;
  }
}

好的,我知道了。我只需要为该部分编写一个重写语句,然后再编写一个测试语句:

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

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

你需要提供更多的信息,比如你的php脚本在哪里,你为什么不在你的表单上设置动作,等等。此外,你正在实现你自己的购物车吗?我在上面添加了更多信息。我们正在使用第三方购物车提供商。