O
O
OneOlOf2020-03-17 03:23:55
Apache HTTP Server
OneOlOf, 2020-03-17 03:23:55

How to redirect to a 404 error page?

There is a server, installed apache. I want to set up the following:
When I enter a URL where there is no index file, I don't want it to open the directory of all files.

Please tell me what needs to be edited so that it redirects to the page with an error.

Change something in .htaccess and this file should be in www/html root? Or change the file in the apache module itself?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-03-17
@OneOlOf

It can be in "httpd.conf", or it can be in ".htaccess". The "Indexes" option is responsible for hiding the directory:
Options -Indexes
After setting it with a minus prefix, if there is no index file, a 403 error will be returned.
The error page can be specified like this:
ErrorDocument 403 /your_403_page.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question