Files on the server loads only when it is accessed through www

January 28, 2015 1.4k views

So I have image on the server located in the images folder.

It serves as a Thumbnail when my site is shared on social media.

But, it can only be viewed when you go to my site with www:

and if you remove www it shows 404:

Does anybody know what is the problem? What do I need to do to fix this?

Thanks in advance.


My droplet is on Ubuntu 14.04

  • What do you have in your apache virtualhost configuration for this domain? Also, is anything being recorded in your error log when the 404 is returned?

  • ok I've just understood what is the problem literally minutes after posting the question.

    in /var/www/ location I have "" and "html" folder.

    both of these folders have version of the site in it.

    When site is accessed through www it reads it from "" folder and when it is accessed without www it reads from "html" folder.

    I need to change (I think) 000-default.conf file to read from folder.

    I'll do that and let you know.

    EDIT: nope didn't do it

1 Answer

Open a console terminal and type:

cd /etc/apache2/sites-available

I don't know how you setup your website via configuration but open the correct file that's associated with

In there, there will be a line that probably says:


Underneath it, add this:


Save and restart apache2

service apache2 restart

Hopefully, that should allow web requests with and without www.

Have another answer? Share your knowledge.