Using .htaccess to restrict visits to login page from all IP's except mine

Viewed 1056

I have a simple PHP website with a login page url like http://sample.com/login

I need to restrict access to the login page from any IP addresses other than mine. But, I dont want to restrict access to any of the other pages on the site. I added the following code to the top of my .htaccess file, but it doesn't seem to be working correctly. Any help anyone can give me with the correct code to add to my .htaccess to only block access to /login/ from other IP's would be much appreciated!

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^xxx.xxx.xxx.xxx
RewriteRule ^/login/$ http://sample.com/$1 [L,R=301,NC]
1 Answers
Related