doupa1883 2016-12-27 20:11
浏览 48

在WordPress托管网站上公开php文件

I just launched a WordPress site that has a form to allow users to select something they want to buy. We are implementing a third-party shopping cart service that requires urls to be in very specific formats. I want to retrieve the POSTed variables and then issue a redirect (basically a GET) to this third-party shopping cart. I was going to just create a buy.php file that did just that- retrieve the POST variables and create the url.

The problem is that I don't know how to expose the buy.php page. I keep getting routed to the 404.html page.

I figured I would create a new location that is before all of the others, but the server log complained about not being able to find the file. Once I fixed that problem, the file wasn't touched, but the request was handled by the 404 page.

The server is running Nginx. Config is below:

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条回答 默认 最新

  • dongzhang0418 2016-12-28 15:13
    关注

    OK, I figured it out. I just needed a rewrite statement for that section, and another to test it:

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类