I've just installed an apache server on Ubuntu, everything went well and I can access the starting page. However, I want to create another page which is located in /var/www/test. I want to be able to access it via address http://xxx.xxx.xxx.xxx/test. I've created the directory, inserted the html file changed my config to this:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

<Directory /var/www/test>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

But unfortunately, when I try to access this page I get an error: Not Found The requested URL was not found on this server.

Apache/2.4.29 (Ubuntu) Server

What am I doing wrong here?


The correspondence between the URL space and files on the disk is ruled by Apache's DocumentRoot directive. If you have in your main or <VirtualHost> configuration file a line like:

DocumentRoot /var/www/html

(you probably have this set in /etc/apache2/sites-enabled/000-default.conf), then whenever you ask the server for http://example.com/path/to/file.html, you will get the content of file /var/www/html/path/to/file.html.

In your case you put a file (probably) called index.html in /var/www/test, but the server is searching for /var/www/html/test/index.html.

The Directory section you added only specifies permissions and other options for /var/www/test, it does not include it in the server's search path. Besides, directory options are inherited, so the /var/www/test directory inherits the options from /var/www (no need to specify the same options again).

  • Thanks, I changed DocumentRoot variable to /var/www/ and it works. – dywan666 Jan 21 at 16:07

First, you don't have to create a new <Directory> block to every directory in your website. Secondly, if you're trying to access the new file without specifying its name, make sure it is an index file. For instance: You've created a /var/www/test/index.html file, you have a DirectoryIndex index.html directive (more examples and information about its use can be found in here) and then you try to access through your browser through http://localhost/test or http://localhost/test/index.html (I'm assuming here that you've configured the DocumentRoot directive pointing to the /var/www directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.