.htaccess - Best way to allow access to members area by IP via PHP or HTACCESS or something else? -


i know if allowing access membership area more efficient htaccess allow or php array of ips check against every page. interested in performance.

are either of these methods recommended when dealing hundreds or thousands of ips?

is there better way?

update:

what if sniffed ip , depending on if ip recognized start membership or none membership session not have check ip every pageview?

it's quicker use htaccess since won't need run php handler run php script. there's similar answer gave for blocking ip addresses utilizes rewritemap. you'd need other way around, instead of denying access ips, grant access:

rewritemap allow_ips txt:/path/to/allow_ips.txt  rewritecond ${allow_ips:%{remote_addr}|0} =1 rewriterule ^protected/path - [l]  rewriterule ^protected/path - [l,f] 

the contents of allow_ips .txt file be:

12.34.56.78 1 11.22.33.44 1 etc. 

the rewritemap directed must in either server or vhost config. can define map htaccess, though can use there.

if can't use maps, you'll need enumerate ips allow. in htaccess file in directory want protect:

order allow,deny deny allow 12.34.56.78 allow 11.22.33.44 ... 

is there better way?

the best way implement user/password via htpasswd. here's tutorial. can put auth* stuff in htaccess file in directory want protect , that's that. simple.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -