0
我有 'www.domain.com',並希望它總是重寫 'domain.com'(只能通過/端口80)Nginx的:NONWWW(80)和重寫一個子域(443)
我也想添加像'c.domain.com'這樣的子域名,總是被重寫(並且只能用於)'https://c.domain.com',但是當我擁有WWW-> NonWWW時,我不知道如何進行另一次重寫。
這是我的配置:
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
server {
listen 80;
server_name www.domain.com;
# redirect www to non-www
rewrite ^/(.*) http://domain.com/$1 permanent;
}
server {
listen 80;
server_name domain.com;
root /usr/share/nginx/$host;
index index.php index.html index.htm;
location/{
try_files $uri $uri/ /index.php?$args =404;
#try_files $uri $uri/;
}
# PHP-FPM
location ~* \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
server {
listen 443 default_server ssl;
server_name c.domain.com;
root /usr/share/nginx/$host;
index index.php index.html index.htm;
}
提前感謝!
謝謝你解釋! – user2100304 2013-02-22 18:32:25