Using mod_rewrite to control access.
https://httpd.apache.org/docs/trunk/rewrite/access.html
