I'm blocking a few IP addresses using the htaccess technique and this works well for all my pages except for the site/document root where the Fedora Core Test Page is displayed instead.
I'm aware that the test page is shown when no document in the root directory is found, thus I have created multiple documents and set the directory index, where index.php is my regular document root file.
NB I don't have access to /etc/httpd/conf.d/welcome.conf
Below is the related htaccess code:
DirectoryIndex index.php index.html 403.php
ErrorDocument 403 /403.php
order allow,deny
deny from 5.39.218
deny from 146.0.74
deny from 5.39.219
deny from 176.102.38
allow from all
<FilesMatch "(403.php|hero.jpg|index.html)$">
order allow,deny
allow from all
</FilesMatch>
Is there a way of displaying my custom 403 page for the website root?
Any suggestions would be much appreciated.
Try this code:
DirectoryIndex index.php index.html 403.php
ErrorDocument 403 /403.php
order allow,deny
allow from all
deny from 5.39.218
deny from 146.0.74
deny from 5.39.219
deny from 176.102.38
Satisfy any
<FilesMatch "^(|403\.php|hero\.jpg)$">
order allow,deny
allow from all
</FilesMatch>
People looking for a complete solution:
Finished Code:
DirectoryIndex index.php index.html 403.php
ErrorDocument 403 /403.php
<FilesMatch "^.*$">
order allow,deny
allow from all
deny from 5.39.218
deny from 146.0.74
deny from 5.39.219
deny from 176.102.38
</FilesMatch>
<FilesMatch "^(|403\.php|hero\.jpg)$">
order allow,deny
allow from all
</FilesMatch>
Try to disable the default Apache CentOS welcome page:
#
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL. To disable the Welcome page, comment
# out all the lines below.
#
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>
Edit file /etc/httpd/conf.d/welcome.conf
and comment everything. Simply removing the welcome.conf
file (or renaming it as .conf.disabled
for example) should do the trick too.
Then, reload apache configuration ( service httpd restart
) and things should work as expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.