我有一个项目,我希望每种语言都有一个域名。所以我的网站指向同一个目录,但出于某种原因,我的一个域名被重定向到另一个域名。
澄清。 example.com example.org
example.org指向与example.com相同的目录。
当我访问example.org时,我被重定向到example.com
我不知道问题是我在两个域上使用LetsEncrypt SSL。
任何线索?
这是我的nginx文件
example.com
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
root /home/forge/example.com;
# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/example.com/xxx/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/xxx/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'XXXXXX-$'
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /(public/mail-signature/.*)$ {
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/after/*;
example.org
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.org/before/*;
server {
listen 80;
listen [::]:80;
server_name example.org;
root /home/forge/example.com;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'xxxxxxx-$'
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.org/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.org-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.org/after/*;
答案 0 :(得分:0)
我建议为你的文档根使用一个更不可知的名称,否则很容易混淆,你可以使用类似的东西:
/home/forge/site-example
稍后尝试使用curl来诊断您的流量,例如:
curl -I -L https://google.com
选项-I
将仅提取标题
选项-L
将遵循重定向
例如,网站http://immortal.run
$ curl -I -L http://immortal.run
HTTP/1.1 301 Moved Permanently
Date: Fri, 15 Sep 2017 14:58:43 GMT
...
HTTP/1.1 200 OK
Date: Fri, 15 Sep 2017 14:58:43 GMT
Content-Type: text/html; charset=utf-8
...
请注意:
HTTP/1.1 301 Moved Permanently
这可能与您的设置有关。