Home > OS >  Deny other than the specified UserAgent
Deny other than the specified UserAgent

Time:09-21

Help me figure out how to configure apache to the settings I need?

domain.zone.conf (what to write here?)

<VirtualHost *:80>
    ServerName sub.domain.zone
    DocumentRoot /var/www/sub.domain.zone
    ServerAlias sub.domain.zone
    ErrorLog /var/www/sub.domain.zone/error.log
    CustomLog /var/www/sub.domain.zone/requests.log combined
</VirtualHost>

You need to make it so that you can go to the subdomain of the site, with the specified UserAgent.

Tried to do like this:

.htaccess

# Encoding
AddDefaultCharset utf-8
# IndexPage
DirectoryIndex index.php
# CloseDirectories
Options All -Indexes
# Control UserAgent
<If "%{HTTP_USER_AGENT} != 'MYUSERAGENT'">
    Require all denied
</If>

Nothing works, I can still log in from any agent.
Tell me how to close access to everyone except the agent I need?

CodePudding user response:

Just use the rewriting module instead:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^MYUSERAGENT$
RewriteRule ^ - [R=403,L]

This rejects any request that does not specify the exact user agent header "MYUSERAGENT" and returns a http status 403 ("Forbidden").

  • Related