User(s) browsing this thread: 1 Guest(s)

2097 views

.htaccess: how to restrict access to a single file by IP?

Author Message
vilivil
Junior Member
**

Posts: 1 Joined: May 2014 Reputation: 0 Status: OFFLINE
Post: #1
.htaccess: how to restrict access to a single file by IP?
I've look all over, but keeps running into same info that talks about directory level IP restriction, which usually looks something like this:

Code:
Order Deny,Allow
Deny from all
Allow from 123.123.123.123

Is it possible to have same type of access restriction tied to a page/document?
05-30-2014 12:58 AM
Find Quote
admin
Administrator
*******

Posts: 11 Joined: Apr 2014 Reputation: 0 Status: OFFLINE
Post: #2
RE: .htaccess: how to restrict access to a single file by IP?
This will allow either someone from IP 127.0.0.1 or logged as a valid user. Stick it either in your config or .htaccess file.
Code:
<Files learn.php>
        Satisfy any
        Order allow,deny
        Deny from all
        Allow from 127.0.0.1

        AuthType Basic
        AuthName "private"
        AuthUserFile /var/www/phpexperts.pro/.htpasswd
        AuthGroupFile /dev/null
        Require valid-user
    </Files>

IP Alone:
Code:
<Files learn.php>
        Order allow,deny
        Deny from all
        Allow from 127.0.0.1
    </Files>
That definitely answers your question.
05-30-2014 12:59 AM
Find Quote
adamo5e
Junior Member
**

Posts: 2 Joined: May 2014 Reputation: 0 Status: OFFLINE
Post: #3
RE: .htaccess: how to restrict access to a single file by IP?
I think the directive needs to be:

Code:
Order deny,allow

for the answer above to work (at least for the IP Alone solution).
05-30-2014 01:01 AM
Find Quote
holy
Junior Member
**

Posts: 3 Joined: Jul 2014 Reputation: 0 Status: OFFLINE
Post: #4
Cvp: .htaccess: how to restrict access to a single file by IP?
Nice share...........
07-15-2014 01:44 PM
Find Quote


Forum Jump: