2

How I can to implement next logic in the virtualhost config :

<VirtualHost *:80>

    ServerName domain.com
    ServerAlias admin.domain.com

    DocumentRoot /usr/.../www

    <Directory /usr/.../www>

        AllowOverride all

        if (%{HTTP_HOST} == 'admin.domain.com') {
            deny from {some ip}
        }

    </Directory>

</VirtualHost>

I need to make admin.explample.com acceseble only from specific IP

1 Answer 1

1

Replace:

    if (%{HTTP_HOST} == 'admin.domain.com') {
        deny from {some ip}
    }

with

RewriteEngine On
RewriteCond %{HTTP_HOST} ^admin\.domain\.com$ [NC]
RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
RewriteRule ^ - [L,F]

where 12.34.56.78 is the IP that you want to be able to access the host. All other IPs will cause a 403 Forbidden result.

1
  • thanks man, sorry for the long answer, just was released from prison on parole Commented Apr 3, 2021 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.