我有3个域名,1个服务器和1个IPv4和1ipv6。 我已经创build了一个logging到我的ipv4(我现在不使用IPv6)。 我的3个网站使用Wordpress。 我为一个域configuration了Nginx和php-fpm。
/etc/nginx/conf.d/php5-fpm:
upstream php5-fpm-sock { server unix:/var/run/php5-fpm.sock; }
/etc/nginx/sites-available/domain.com.conf:
server { listen 80; server_name domain.com; root /var/www/domain.com; index index.php index.html; #charset koi8-r; access_log /var/log/nginx/domain.com.access.log; error_log /var/log/nginx/domain.com.error.log; #include global/common.conf; #include global/wordpress.conf; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass php5-fpm-sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } }
/etc/nginx/sites-available/totaly-different-domain.com.conf:
server { listen 80; server_name totaly-different-domain.com; root /var/www/totaly-different-domain.com; index index.php index.html; #charset koi8-r; access_log /var/log/nginx/totaly-different-domain.com.access.log; error_log /var/log/nginx/totaly-different-domain.com.error.log; #include global/common.conf; #include global/wordpress.conf; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass php5-fpm-sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } }
问题:当我键入domain.com时,域1出现在我的导航器上,而且还input了totaly-different-domain.com。
PS:我知道我可以优化,但我想明白为什么我有这个问题之前。
更新1 :
这是我的工作文件:
/etc/nginx/sites-available/domain.com.conf:
server { server_name domain.com www.domain.com; root /var/www/domain.com/; index index.php index.html; access_log /var/log/nginx/domain.com.access.log; error_log /var/log/nginx/domain.com.error.log; include global/common.conf; include global/wordpress.conf; }
/etc/nginx/sites-available/totaly-different-domain.com.conf:
server { server_name totaly-different-domain.com www.totaly-different-domain.com; root /var/www/totaly-different-domain.com/; index index.php index.html; access_log /var/log/nginx/totaly-different-domain.com.access.log; error_log /var/log/nginx/totaly-different-domain.com.error.log; include global/common.conf; include global/wordpress.conf; }
/etc/nginx/global/common.conf:
# Global configuration file. # ESSENTIAL : Configure Nginx Listening Port listen 80; # ESSENTIAL : Default file to serve. If the first file isn't found, index index.php index.html index.htm; # ESSENTIAL : no favicon logs location = /favicon.ico { log_not_found off; access_log off; } # ESSENTIAL : robots.txt location = /robots.txt { allow all; log_not_found off; access_log off; } # ESSENTIAL : Configure 404 Pages error_page 404 /404.html; # ESSENTIAL : Configure 50x Pages error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # SECURITY : Deny all attempts to access hidden files .abcde location ~ /\. { access_log off; log_not_found off; deny all; } # PERFORMANCE : Set expires headers for static files and turn off logging. location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|$ access_log off; log_not_found off; expires 30d; }
/etc/nginx/global/wordpress.conf:
# WORDPRESS : Rewrite rules, sends everything through index.php and keeps the a$ location / { try_files $uri $uri/ /index.php?$args; } # SECURITY : Deny all attempts to access PHP Files in the uploads directory location ~* /(?:uploads|files)/.*\.php$ { deny all; } # REQUIREMENTS : Enable PHP Support location ~ \.php$ { # SECURITY : Zero day Exploit Protection try_files $uri =404; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php5-fpm-sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; }
好的,我find解决scheme。 您必须更换:
server_name totaly-different-domain.com;
通过
server_name totaly-different-domain.com www.totaly-different-domain.com;
同样的事情为domain.com。
你不需要更换
server_name totaly-different-domain.com;
同
server_name totaly-different-domain.com www.totaly-different-domain.com;
使用您发布的configuration,我无法重现您的问题。 你的问题不在你的configuration中。
试用临时replaceindex.php的内容
<?php echo $_SERVER['SERVER_NAME']; ?>
并访问每个网站。 如果为每个域显示正确的服务器名称,您可能会发现此链接有帮助。 http://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/