我的网站有问题。 每当我尝试访问我的网站时,都不会redirect。
这意味着当我inputURL作为financenectar.com它打开我的网站在financenectar.com但不redirect到www.financenectar.com。
还有一件事,当我inputwww.financenectar.com时,它甚至没有工作。
server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www/financenectar/; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name financenectar.com; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.php?q=$uri&$args; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini try_files $uri =404; # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
请让我知道这些变化。
您没有任何包含www.financenectar.com的服务器块。
我有一些可能的解决scheme给你。
更改以下行
server_name financenectar.com;
对此
server_name financenectar.com www.financenectar.com;
这将使nginxconfiguration适用于这两个域,但没有redirect。
添加一个新的服务器块与以下内容。
server { listen 80; root /var/www/financenectar/; server_name www.financenectar.com; location / { return 301 http://financenectar.com$request_uri; } }
这使所有请求www.financenectar.comredirect到financenectar.com。 如果你想换一个方法,只要切换每个服务器块中的server_name参数,并将上面configuration中的return参数更改为以下内容。
return 301 http://www.financenectar.com$request_uri;