我遇到了一个问题,几乎要解决了,但最后一步却失败了。
我有一个 WP 安装于www.example.com在 Ubuntu/Nginx 上我没有遇到任何问题,我还想为我们的德国网站安装另一个带有 /de 的版本,例如(www.example.com/de) 结构,但是,我想将 wordpress 源文件保存在德国网站的单独文件夹下,而不是将它们放在主网站的子文件夹中,因此根位置将是:
主站点的根目录 (www.example.com) -> var/www/example.com 德国网站的根目录 (www.example.com/de)-> var/www/example.com-de
我已经设置了以下配置文件,我可以访问德国网站的主页,并且没有启用任何永久链接,一切正常,但是当我激活漂亮的链接时,它会带我回到实际域名“www.example.com”
我按照本教程进行操作,直到最后一步,一切都顺利:
https://serversforhackers.com/c/nginx-php-in-subdirectory
server {
listen 80;
listen [::]:80;
root /var/www/example.com;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com 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?$args;
}
location /de {
alias /var/www/example.com.de;
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
有人能指出我在配置文件中遗漏了什么吗?这是否是设置我想要实现的目标的最优化方法?
提前谢谢了。