我遇到了一个指向域的问题
example.com
返回404,而子域
stage.example.com
指向同一资源的行为与预期一致。我在ubuntu上用nginx 1.10.3运行这个。
这是此服务器的配置文件(
/etc/nginx/sites-available/example.com
符号链接到
/etc/nginx/sites-enabled/example.com
)
server {
# Root directory
root /home/username/example.com;
# Index
index index.php index.html index.htm index.nginx-debian.html;
# Server name(s)
server_name stage.example.com example.com www.example.com;
# Create access and error logs in /var/log/nginx
# access_log /var/log/nginx/example_com-access_log;
# error_log /var/log/nginx/example_com-error_log info;
# Generic location
location / {
# First attempt to serve request as file, the fall back
# to allow hashless routing
try_files $uri $uri/ /index.php;
}
location ~ \.json$ {
# Patching existing loading of JSON via post
# To allow POST on static pages
error_page 405 =200 $uri;
}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# route to headless use of wordpress
location /content/ {
try_files $uri $uri/ /content/index.php$is_args$args;
}
# route to api in headless wordpress
location ~ ^/api/ {
# if permalinks not enabled
rewrite ^/api/(.*?)$ /?rest_route=/$1 last;
}
# Deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
思想?