问题
On my Authentication page i have it only allow from certain IPs. Is it possible to have it allow by a domain name? The IP of my home network is dynamic but the domain name (mysite.com) always points to the correct IP address.
回答1:
Yes you can. Your .htacces would look like
order deny,allow
deny from all
allow from mysite.com
回答2:
I came across this because I had the same problem.
Just in case anyone else finds this, I found the perfect solution:
Beginning in Apache 2.4.19, you can use the parameter "Require forward-dns [hostname]", which simply allows all IPs behind [hostname].
https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html#requiredirectives
回答3:
protect a folder:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://([a-z0-9-]+\.)*your-domain.com/ [NC]
RewriteRule /* http://%{HTTP_HOST}/ [R,L]
来源:https://stackoverflow.com/questions/28376037/htaccess-allow-from-domain-name-instead-of-ip-subnet