不少高優化的朋友,都須要從 exp.com 跳轉到www.exp.com的需求吧,大多時候能夠在第三方域名服務商那邊實現,但有的不能,就須要咱們本身來實現了,下面是nginx的配置文件php
#先監聽 exp.com域名,而後轉發到www下面 server { listen 80; server_name exp.com; rewrite ^(.*) $scheme://www.$server_name$1 permanent; } #www.exp.com配置 server { listen 80; root path; server_name www.exp.com; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }