Results 1 to 10 of 17

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default .htaccess code to only allow access to my IP address?

    Is there any code I can add to the .htaccess file on my development site to only allow access to the admin IP address? i.e only allow access to the store to the admin when logged into the admin area?
    Phil Rogers
    A problem shared is a problem solved.

  2. #2

    Default Re: .htaccess code to only allow access to admin IP address?

    Code:
    Order Deny,Allow
    Deny from all
    Allow from adminip
    I was test with my site http://trihung.com

  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: .htaccess code to only allow access to admin IP address?

    Quote Originally Posted by thanhv View Post
    Code:
    Order Deny,Allow
    Deny from all
    Allow from adminip
    I was test with my site http://trihung.com
    so the .htaccess dynamically knows what 'adminip' is??
    Phil Rogers
    A problem shared is a problem solved.

  4. #4
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: .htaccess code to only allow access to admin IP address?

    nope.. that doesnt work

    im assuming you are meaning to hard code in my ip.. my ip changes, I want it to allow based on the current admin ip.

    anyone else know how to achieve this?
    Phil Rogers
    A problem shared is a problem solved.

  5. #5
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: .htaccess code to only allow access to admin IP address?

    You could try putting the site into "maintenance" mode. This will by default only allow the IP Addresses you add in the admin area to browse the store. Although if I remember correctly some features such as downloadable products do not always work in "maintenance" mode. You could also just go in via SFTP / FTPS and edit the allowed IP address each time.

    If you just don't want search engines to crawl / index the site you can add a robots.txt to request they ignore all URLs on your site / folder.

    If you do not want the world to access your development site:
    1. Site on a PUBLIC facing webserver, use static IPs on the clients and configure to allow only those IPs.
    2. Site on a PUBLIC facing webserver, use a authentication method (Apache or another method).
    3. Move the development site to a NON-PUBLIC facing webserver, use VPN / SSH Tunnel / etc to access network remotely. This lets multiple team members work on the website at the same time. In conjunction with version control (such as GIT / SVN) and project management software this works well.
    4. Move the development site to your local computer, block external requests. Good for local testing of websites + email generation.

    I do a combination of the last two... I test my changes locally and when done: commit to VCS (in my setup this goes to a shared development server for regression + unit testing) and log my changes to the PM software. In a few cases I have had a business need for a PUBLIC facing webserver for testing, but it is rare.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  6. #6
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: .htaccess code to only allow access to admin IP address?

    Quote Originally Posted by philip937 View Post
    nope.. that doesnt work

    im assuming you are meaning to hard code in my ip.. my ip changes, I want it to allow based on the current admin ip.

    anyone else know how to achieve this?
    Set up to use a 'Dynamic DNS' and use hostname instead of IP address in the 'Allow From'

    Alternatively, ask your ISP the range of IP addresses from the pool they assign to you and allow only those IP's. (keeping in mind that this will still allow anyone using the same ISP as you 'unrestricted' access.

    If you prefer to keep things simpler, just restrict the admin folder(s) via a .htaccess password. It's just as secure, with little chance of locking yourself out.

    Cheers
    Rod

  7. #7
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: .htaccess code to only allow access to admin IP address?

    How does the store front look in maintainance mode? Is there just access to a single holding page unless you are admin? Where are the ip addresses set?
    Thanks
    Phil Rogers
    A problem shared is a problem solved.

  8. #8
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: .htaccess code to only allow access to admin IP address?

    just tried it, down for maintenance is perfect, does exactly what I need :o)
    Phil Rogers
    A problem shared is a problem solved.

  9. #9
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: .htaccess code to only allow access to admin IP address?

    Quote Originally Posted by philip937 View Post
    How does the store front look in maintainance mode? Is there just access to a single holding page unless you are admin?
    Yes (as you have discovered).

    What you may not realise is that this page can be customised. Darnit. I forget the name of the file.

    Quote Originally Posted by philip937 View Post
    Where are the ip addresses set?
    Thanks
    This is set by ZenCart based on the IP address of the admin user currently logged in (I think).

    I don't know when this gets reset, but I'd assume that if you happened to lose connection to your ISP whilst in maintainance mode and get assigned a new IP address you could find yourself locked out of the system (Don't panic, this would be rare, and there are ways to recover)

    Cheers
    Rod

 

 

Similar Threads

  1. v151 How to allow a guest to access only certain products
    By jodean in forum General Questions
    Replies: 2
    Last Post: 31 Aug 2015, 05:00 AM
  2. using a new .htaccess file to allow specific access?
    By torvista in forum General Questions
    Replies: 2
    Last Post: 7 May 2010, 07:03 PM
  3. Can I allow certain users to have access to only certain categories?
    By bparker in forum Customization from the Admin
    Replies: 2
    Last Post: 8 Sep 2009, 08:41 PM
  4. Allow to download a file only with a code
    By trec in forum General Questions
    Replies: 0
    Last Post: 7 Sep 2009, 01:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg