Allow Deny visitors by IP using .htaccess
There must be a solid reason to do this. By using the little code below, we can easily make our website accessible or inaccessible to the specific visitors using their IP (You need to know the visitors IP of course). You need to just copy and paste it in your .htaccess file.
order allow,deny
deny from 255.0.0.0
deny from 123.45.6.
allow from all
Deny: means IP which you want to block, in the example above, we have blocked two IPs and allowed everyone else. Use this .htaccess wisely.
Many times web developers work on the live server instead of localhost. In this case, it is good practice to block all IPs but one and develop the site without any worry. To do so, add this to your .htaccess file
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For} xxx\.xxx\.xxx\.xxx
RewriteRule .* - [F]
Remove xxx\.xxx\.xxx\.xxx and put your IP address.
Done.
If you have any issue, let us know in the comment box.
Latest
SOLID Principles: A Comprehensive Guide with Examples
Dec 22, 2024
React useEffect, useMemo, and useCallback: A Comprehensive Guide
Nov 23, 2024
React Component Structure, Composition, HOCs and Optimization with Examples
Oct 4, 2023
How to copy text to the clipboard in React.js
Sep 29, 2023
News
Pure html popover API is coming in Chromium 114
Sep 24, 2023
GitHub and OpenAI launch Copilot - an AI pair programmer
Jul 1, 2021
CSS aspect-ratio property
Jan 31, 2021
AWS UI - a collection of React components
Jan 20, 2021
Featured
SOLID Principles: A Comprehensive Guide with Examples
Dec 22, 2024
React useEffect, useMemo, and useCallback: A Comprehensive Guide
Nov 23, 2024
Axios Interceptors in a React application
May 27, 2023
Mastering Laravel: Exploring the Power of implode() and explode() Functions for String Manipulation
May 22, 2023