2

Apache2 doesn't automatically find the index page. If I go to the (IP) address -I haven't bought a domain yet- where i should find the index page i receive the Server not found error.

I reinstalled Apache2 after a apt-get remove --purge apache2 apache2-utils but it doesn't change. If I go to http://ipaddress/index.html it works. I have the same problem with all index pages (or install.php pages for exaple).

There's no httpd.conf only apache2.conf and 000-default.conf in site-available.

000-default.conf:

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html>
        DirectoryIndex index.php index.html
    </Directory>

</VirtualHost>

.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

I'm on Ubuntu Server 18.04 with mysql,php7.2 and apache2 installed.

2
  • 1
    lets see your .htaccess or vhosts config Commented Oct 15, 2018 at 14:55
  • Look at httpd.conf and check for or add a DirectoryIndex index.php index.html index.htm Commented Oct 15, 2018 at 15:02

1 Answer 1

1

Create an .htaccess file or add this string to your .htaccess file. This will tell to apache what file is the default index of your website.

DirectoryIndex index.php index.html

Or you can add this lines to your httpd.conf file

<Directory /yourapp>
DirectoryIndex index.php index.html
</Directory>
Sign up to request clarification or add additional context in comments.

4 Comments

As OP seems to have full access to Apache doing this in the httpd.conf file would be more efficient
@RiggsFolly ok, I've edited the answer to add the httpd.conf solution
I would suggest <IfModule dir_module> DirectoryIndex index.php index.html index.htm </IfModule> and not in the <Directory ....>` would make it global rather than specific to one directory
Then of course we should also check that the LoadModule dir_module modules/mod_dir.so extension is activated as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.