Question
0curl: (6) Could not resolve host: mydomain.com after Redirect non-www to www with Nginx
I’ve followed a tutorial post about redirect on Digital Ocean’s community.
But things didn’t worked for me as in the tutorial.
Below is my server block code for redirect from config file /etc/nginx/conf.d/redirect.conf
:
server {
server_name www.crusadehimalaya.com;
return 301 $scheme://crusadehimalaya.com$request_uri;
}
I’ve also added A record with “www” ** and **@
Running curl -I http://www.crusadehimalaya.com
gives the following response
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 194 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
HTTP/1.1 301 Moved Permanently
Server: nginx/1.14.0 (Ubuntu)
Date: Tue, 04 Dec 2018 07:45:15 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: http://crusadehimalaya.com/
Running curl -I http://crusadehimalaya.com
Gives following output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: crusadehimalaya.com
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
@crucadehumalaya
I see no problem in here, did you fix it?
I can open www.crusadehimalaya.com from a browser and it redirects to crusadehimalaya.com without any errors