我的NGINX服务器在网站的配置文件中添加了location/
的代码。我有最新版本的WordPress和WooCommerce。
即使我更改主题(默认)并停用除WooCommerce之外的所有插件,问题仍然存在。当永久链接处于默认状态时(例如www.example.com/?page_id=5
),一切正常;我可以在购物车中添加和更新产品。
如果我将固定链接更改为更好的"格式(例如www.example.com/cart/
)虽然我可以通过浏览器访问页面www.example.com/cart/
,但在控制台中我得到以下内容:
获取http://www.example.com/cart/ 404(未找到)
导航到http://www.example.com/cart/
当我尝试通过按添加到购物车或更新购物车按钮来添加或更新产品时,在购物车产品页面或购物车页面中没有任何反应,控制台会报告错误。
有谁能建议我从哪里开始挖掘?
nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 50M;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
# gia 504 gateway time-out fix
fastcgi_connect_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
#pros8esa mpas kai lisi to 502 bad gateway
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
#log_format compression '$remote_addr - $remote_user [$time_local] '
# '"$request" $status $bytes_sent '
# '"$http_referer" "$http_user_agent" "$gzip_ratio"';
#log_format compression '$remote_addr - $remote_user [$time_local] '
# '"$request" $status $body_bytes_sent '
# '"$http_referer" "$http_user_agent" "$gzip_ratio"';
log_format main '"$remote_addr" $host [$time_local] '
'"$request" $status $body_bytes_sent '
'$request_length $bytes_sent "$http_referer" '
'"$http_user_agent" $request_time "$gzip_ratio"';
# server {
# gzip on;
# access_log /var/log/nginx/access.log compression;
# }
#access_log /var/log/nginx/access.log compression buffer=32k;
#error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log crit;
access_log off;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
网站启用文件
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
listen 80; #default_server;
#listen [::]:80 default_server ipv6only=on;
root /var/www/example.com/htdocs;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name www.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?q=$uri$args =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /index.php;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 1000;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#sef url
}
server {
server_name example.com;
rewrite ^(.*) http://www.example.com$1 permanent;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
答案 0 :(得分:0)
您的vertex.executeBlocking(event->{
network.registart(new CallBack(){
public void newData(Data d)
{
runThisCodeInEventLoop(); // I want to run this code in the event loop.
event.complete();
}
},false,ev->{
....some code...
}
}
声明中有错误。它应该是:
try_files
或(我用的是):
location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}
location / {
try_files $uri $uri/ /index.php;
}
指令只能有一个默认值。有关详细信息,请参阅this document。