Issue
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
Solution
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.
Answered By - Jon Lin Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.