0
我一直在嘗試過去幾天讓這個工作正常,但我很快就來了。nginx強制SSL沒有www重定向問題
(計算器不允許我發表兩個以上的實測環節 - 忽略反斜槓)
通常的結果是,example\.net
和www.example\.net
會重定向到HTTP \ S://example.net,而http\s://www.example\.net
將不會重定向到http \ s://example.net,而另一種常見情況是來自瀏覽器的聲明該頁面沒有正確重定向的消息。
我想要做的是強制絕對所有請求去http \ s://example.net$request_uri。
example\.net => http\s://example\.net
www.example\.net => http\s://example\.net
https://www.example\.net => http\s://example\.net
nginx的站點配置:
upstream backend {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name www.example\.net example.net;
return 301 http\s://example\.net$request_uri;
}
server {
listen 443 ssl default_server;
server_name example\.net;
include snippets/snakeoil.conf;
root /var/www/html/example;
charset utf-8;
index index.php;
access_log /var/log/example-access.log;
error_log /var/log/example-error.log;
location/{
try_files $uri $uri/ @extensionless-php;
index index.php;
}
location ~ .php {
try_files $uri =404;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
誰能告訴我什麼,我做錯了什麼?