2016-12-27 103 views
0

我剛剛推出了一個WordPress網站,其中有一個表單,允許用戶選擇他們想要購買的東西。我們正在實施第三方購物車服務,要求網址採用非常特定的格式。我想要檢索POST的變量,然後發出重定向(基本上是一個GET)到這個第三方購物車。我打算創建一個buy.php文件來完成這個工作 - 檢索POST變量並創建url。在WordPress託管網站上公開PHP文件

問題是我不知道如何顯示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; 
    } 
} 
+0

您需要提供更多的信息,等,其中你的PHP腳本,你爲什麼不設置你的表格,等在行動另外你是否正在實施自己的購物車? – cmorrissey

+0

我在上面添加了更多信息。我們正在使用第三方購物車提供商。 – Scott

回答

0

好的,我想通了。我只需要爲部分重寫語句,另一個對其進行測試:

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

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