Hi.
I have been trying to add www to my domain like this:
from this:
to this:
I was following this article here: https://www.digitalocean.com/community/articles/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx
but ended up with no result. I believe it is something related to either ect/nginx/nginx.config or my domain file in sites-available…
There is one question I also want to ask, if the domain re-directed from http://domain.com to http://www.domain.com, would that be considered an extra http request. is there a way how to avoid extra requests?
any idea how that can go correct??
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Look at here:
According to this link the solution is:
server {
server_name domain1.com;
rewrite ^(.*) http://www.domain1.com$1 permanent;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/user/www/domain1;
index index.php index.html index.htm;
server_name www.domain1.com;
include hhvm.conf;
}
Oh, wait. Do you mean you really want a redirect, such that if a visitor types in ‘domain.com’, they will be redirected to ‘www.domain.com’? My response doesn’t help with that, it only enables the server to handle the ‘www’ form (or both forms, depending on which version you use).
Thanks @matt. <br> <br>I’ve already added www to my DNS. <br> <br>if I added www to the domain in the etc/nginx/sites-available/mydomain, not at nginx.conf in the nginx root folder. <br> <br>That works, but counted as an extra request. so an empty page takes 2 requests, which is a bad practice. <br> <br>I believe there a way how to do that, but not sure yet how!! <br> <br>regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.