Wordpress 如何使用nginx将URI(位置路径)传递给代理?
我正在使用WordPress和nginx 我需要设置2个访问位置:Wordpress 如何使用nginx将URI(位置路径)传递给代理?,wordpress,nginx,Wordpress,Nginx,我正在使用WordPress和nginx 我需要设置2个访问位置: mydomainname.com/-nginx将返回静态文件 mydomainname.com/wordpress-nginx将传递给PHP/wordpress 我有以下nginx配置文件: # https://mydomainname.com - Port 443 =========================================== server { listen 127.0.
- mydomainname.com/-nginx将返回静态文件
- mydomainname.com/wordpress-nginx将传递给PHP/wordpress
# https://mydomainname.com - Port 443 ===========================================
server {
listen 127.0.0.1 ssl;
server_name mydomainname.com;
ssl_certificate /usr/local/etc/letsencrypt/live/mydomainname.com/fullchain.pem;
ssl_certificate_key /usr/local/etc/letsencrypt/live/mydomainname.com/privkey.pem;
ssl_trusted_certificate /usr/local/etc/letsencrypt/live/mydomainname.com/fullchain.pem;
include /usr/local/nginx/conf/ssl.conf;
location / {
root /usr/local/www/mydomainname.com;
index index.html;
}
index index.php;
location /wordpress { # I also tried "/wordpress/"
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
root /usr/local/www/mydomainname.com/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我想我知道问题所在:URI“/wordpress”或“/wordpress”被删除,而不是传递给PHP/wordpress
我正在试图找出如何将“/wordpress”或“/wordpress/”路径传递到PHP/wordpress
我试过了,但没用
有人能帮忙吗?谢谢 将
root
语句移动到server
块中,并允许所有位置块继承相同的值。此外,WordPress URI的前缀应为/WordPress/
例如:
root /usr/local/www/mydomainname.com;
location / {
index index.html;
}
location /wordpress {
index index.php;
try_files $uri $uri/ /wordpress/index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
嗯,我试过了,但没用。看起来好像有一个打字错误,try_files$uri=404;“”。我试图解决它,但我认为它不是“try_files$uri$uri//wordpress/index.php?$args;”,因为它正在查找wordpress目录。它应该是“try_files$uri$uri//index.php?$args;”,但将“wordpress”作为uri传递到请求中。我该怎么做?