By newbie
Hello, i have created my droplet with the hostname website.com(example) and then add a CNAME with www that points my site. now my site with www shows one 301 redirect. how can i change this state. i want to remove that 301 redirect from www and want to add that redirect to website.com so that anyone who type website.com lands in www.website.com and www.website.com stays without any redirect. im on ubuntu 14.04 with apache
regards
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!
Assuming you are using Apache, you can set up a redirect from the non-www url to the www url by setting up a new VirtualHost that just redirects to the other one. It would look something like:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
#
# All your normal configuration
#
</VirtualHost>
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.