Non-www shows empty directory listing. www. works fine.

Posted April 2, 2020 687 views
ApacheWordPressUbuntu 18.04


I’m running Wordpress 5.4 on Ubuntu 18.04.1 and Apache/2.4.29.

When I go to I see this empty directory listing.

But works fine.

Also working fine is a 301 redirect I have in htaccess. As well as any redirect from to and HTTPS.

It’s only the root non-www. that does this.

Here is my htaccess but maybe this is something to do with a DNS record or even virtual hosts?

I’m not sure where to look next any help would be really appreciated.

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.

Submit an Answer
1 answer

Hi there @ellebovski,

It sounds like that you don’t have your non-www version added to your Apache virtual host.

You need to make sure that you have both the www and the non-www verion specified in your ServerName and ServerAlias lists in your Apache Vhost. To check that you can do the following:

  • Open your Apache Vhost with your favorite text editor:
sudo nano /etc/apache2/sites-enabled/your_domain.conf
  • Update your ServerName to match your non-www version

  • Add a ServerAlias to match your www version

  • Then run a config test:

  • sudo apachectl -t
  • If you get Syntax OK then restart Apache:
  • sudo systemctl restart apache2

Let me know if you have any questions.

  • Thanks a lot @bobbyiliev

    I may be mistaken but I think I have that in place already as per this conf file.

    I have three .conf files in that folder; the default one, the one I linked above for SSL and the original before SSL was added. Is that normal?

    Here is the first few lines of apache2ctl -S in case that helps…?

    root@example:/etc/apache2/sites-enabled# apache2ctl -S
    VirtualHost configuration:
    *:443         (/etc/apache2/sites-enabled/
    *:80                   is a NameVirtualHost
             default server (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost (/etc/apache2/sites-enabled/
    • Hi there @ellebovski,

      The config file that you’ve shared actually looks correct.

      However, the output of the apache2ctl -S command makes me think that you have a duplicate entry for your domain name in your default config file and the original config file for your

      What I could suggest is making sure that in your default config file you don’t have anything specified as the ServerName, you can comment that line by adding a # sign before the `ServerName, it would look like this:


      Then run a config test and restart Apache.

      Let me know how it goes!