Using .htaccess will let you control who is able to access and view different areas of your website. Learn how to block access to an IP address in this article.
order allow,deny allow from all # Jordan's IP address deny from 220.127.116.11 # Kate's IP address deny from 18.104.22.168
You may prevent people from accessing your website by blocking their IP address. In the sample above, the .htaccess file will allow everyone to visit the website except for two IP addresses. The two IP addresses are mine (22.214.171.124) and my friend Kate’s (126.96.36.199). Copy the code above and replace the IP addresses that you want to block access from. Place the .htaccess at the root level of your website.
<Files CheatCodes.php> order allow,deny allow from all # Garrett's computer deny from 188.8.131.52 </Files>
The sample above demonstrates how you can restrict access to a particular file on your website. In the sample above, everyone is given access to view the CheatCodes.php file except for my brother Garrett. You have several options for placing the .htaccess file on your website. You can place it at your site’s root .htaccess or you can place it in the CheatCodes.php’s file location. Just make sure that you specify the file path if you are placing the code outside of your CheatCode.php file’s directory. ex)
order allow,deny allow from all # Garrett's computer deny from 184.108.40.206
This is very similar to how you block an IP address from accessing our website. Instead of placing the code shown above in your website’s root folder, you will be creating a new .htaccess file and placing it in the directory that you wish to block users from accessing. The .htaccess rules will apply to all sub directories so you will not have to worry about creating subsequent .htaccess files for any new folders.
You may be interested in allowing access from an IP address