Would you like to learn how to install Apache and deny the USER-AGENT access? In this tutorial, we are going to configure the Apache server to block access to your website based on the USER-AGENT value.
• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Apache 2.4.41
In our example, the Apache server is hosting the website WWW.GAMEKING.TIPS.
Copyright © 2018-2021 by Techexpert.tips.
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the publisher.
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Apache – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Apache.
Tutorial Apache – Blocking the USER-AGENT access
Install the Apache server.
Enable the required Apache modules.
Edit the Apache configuration file for the default website.
Add the following lines to this configuration file.
Change the USER-AGENT values to reflect your needs.
Here is the file, before our configuration.
Here is the file, after our configuration.
Restart the Apache service.
In our example, the Apache server will forbid access from USER-AGENTS with the word YANDEX or BINGBOT.
In our example, the Apache server will allow access from any other USER-AGENT.
From a remote Linux computer, test your configuration.
Here is the command output.
The Apache server will forbid access from specific USER-AGENT values.
From a remote Linux computer, try to perform access using any other USER-AGENT value.
Here is the command output.
The Apache server will allow any other USER-AGENT value to access your website.
Congratulation! You configured the Apache server to deny access based on the USER-AGENT value.
Tutorial Apache – Deny the USER-AGENT using HTACCESS
Install the Apache server.
Enable the required Apache modules.
Edit the Apache configuration file.
Add the following lines at the end of the file.
Create an HTACCESS file on the website directory.
Add the following lines to this configuration file.
Change this line to reflect your needs.
Configure the correct file permission.
Restart the Apache service.
In our example, the Apache server will forbid access from USER-AGENTS with the word YANDEX or BINGBOT.
From a remote Linux computer, test your configuration.
Here is the command output.
The Apache server will deny access from specific USER-AGENT values.
Congratulation! You configured the Apache server to deny access based on the USER-AGENT value using an HTACCESS file.