Welcome to WebmasterWorld Guest from 54.161.25.213

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Requiring authentication for external IP

     
7:32 pm on Feb 3, 2014 (gmt 0)

Junior Member from CZ 

5+ Year Member

joined:Jan 29, 2010
posts: 46
votes: 0


Hi,

Is it possible to make a rule in .htaccess with the following conditions:

If the origin IP comes from internal network, pass to home page.

else

if the origin IP is not internal network then direct to login page.

Im unsure of the search term so any help would be great.
8:04 pm on Feb 3, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13741
votes: 459


Are you asking about your own internal network, such as an institutional site? Not any old internal network generically, right?

If the network has its own IP address that isn't used by anyone else, all you need is a {REMOTE_ADDR} condition. There are other approaches, but that's the simplest.
8:21 pm on Feb 3, 2014 (gmt 0)

Junior Member from CZ 

5+ Year Member

joined:Jan 29, 2010
posts: 46
votes: 0


Yes you are correct. I have an intranet that users can view a "intranet" website. So what I am attempting to do is state if the request comes from anything other than the 10.0.0.0/8 network then use the .htpasswd file to request authentication or a login page whatever is easier.
8:38 pm on Feb 3, 2014 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10858
votes: 67


if the origin IP is not internal network then direct to login page.


it depends on what you mean by a "login page".
if HTTP Basic authentication is sufficient, you could do something like this:
<RequireAny>
Require ip 10
Require valid-user
</RequireAny>

and also your AuthType and other required authentication directives.

if you need a login web page then you could use mod_rewrite to redirect the visitor to the login page.
11:55 pm on Feb 3, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13741
votes: 459


<RequireAny>

:: detour to Apache docs ::

Oh, I see. In 2.2 "Require" is only a directive. In 2.4 it's also an envelope, with "RequireAll" and "RequireAny" options. And it's all shifted from core to a named mod. At this point it's probably safe to assume 2.2 though.

http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#logic

(de-linked to preserve fragment) Sometimes you have to wonder if they're intentionally trying to terrorize us.