Restrict access to WordPress site
H开发者_运维技巧ow to make only certain IP addresses allowed to access my website. Currently I'm using wordpress. I want to make it so that if the user IP is not on the list the page will redirect to another site. Please help me.
If you're on an Apache server (and AllowOverride
is enabled) you could do this by making a file called .htaccess
in the directory you want to restrict access to and enter:
Order deny,allow
Deny from all
Allow from 1.2.3.4 # replace this with your IP
Alternatively you could do this in your main Apache configuration, with a <Directory>
directive but you won't be able to do this if you're on shared hosting. (Bit of a mini-assumption there, hence the .htaccess solution)
There are also other methods, for example editing your PHP to check the $_SERVER['REMOTE_ADDR']
value and die
accordingly.
You can use this WordPress plugin called Restricted Site Access.
精彩评论