I have a website hosted on Apache server and on Ubuntu machine. When the visitor type mydomain.com/index.html I would like to redirect it to the custom 404 page error.
So in the /etc/apache2/sites-available
I edit the mydomain.com.conf
file in the folling way:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorDocument 403 /custom_403.html
ErrorDocument 404 /custom_404.html
Redirect 404 /index.html
But now when I type www.mydomain.com
the Apache doesn´t load neither the index.html
nor the custom_404.html
. Instead, it shows a folder structure with what I have in the DocumentRoot
.
How can I achive my goal without this issue? Thanks
I found a way to prevent users to access the website by writing mydomain.com/index.html
. I edited the file /etc/apache2/mods-available/dir.conf
and in the line where is write DirectoryIndex
I changed index.html
by somethingElse.html
. Then in the DocumentRoot
I also changed the name of index.html
by somethingElse.html
.
I kept the configuration of the file /etc/apache2/sites-available/mydomain.com.conf
so every time the user type mydomain.com/index.html
it gets a 404
error custom page.