cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict access to admin by IP?

Restrict access to admin by IP?

 We would like to restrict access to the admin login to our local domain, and admins connected via VPN.  I know we can do this via htaccess, but is there a better way? Every extension I see is for community edition, and the one we tested on a development server broke the system temporarily. 

 

So, what is everyone else using to restrict access to admin?

 

Magento1

EE 1.14

5 REPLIES 5

Re: Restrict access to admin by IP?

I wouldn't recommend using an extension when this can be easily achievable with the .htaccess method. 

 

This is because with .htaccess based blocking, non-authorized users will not be able to even access your application before being blocked unlike an extension based solution where they need to access your application first for the extension to block them. 

 

Besides that, adding too many extensions will just cause a lot of complications when you want to upgrade in the future as many extensions are not properly supported and may not be compatible with newer versions or security patches. 

Re: Restrict access to admin by IP?

Hello,

 

Lately come to this place, I need your help please.

 

I need to deny admin url access for all, but allow only certain IP address.

Please can you tell me which .htaccess and on which line I should add and which code I need to use?

 

I search on google but could not get which .htaccess and on which line.

 

Thank you in advance.

Van

Re: Restrict access to admin by IP?

Adding the following lines to your .htaccess file should do the job:-

RewriteCond %{REQUEST_URI} ^/(index.php/)?admin(.*) [NC] 
RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1
RewriteCond %{REMOTE_ADDR} !^2\.2\.2\.2
RewriteRule .* - [F,L]

Where 1.1.1.1 and 2.2.2.2 are your IP addresses. 

 

 

Re: Restrict access to admin by IP?

Hello James,

 

I used your code and it work perfect, but we can open only home page, rest of the pages has 'not available' error with 404.

What to do with this, please help again.

 

Thank you for your code.

 

Regards

VL

Re: Restrict access to admin by IP?

Did you touch any lines of the original .htaccess file? 

 

404 problems for subpages are usually caused by the default .htaccess file not present or it's tampered with.