We have a page, gateway.school.edu, where users have to fill out a recaptcha before being directed forward to our password reset. I would like any internal traffic, any user agent on our network with a 10., 172. or 192.* IP, to get passed through without having to fill out the recaptcha. So an internal user would navigate to gateway.school.edu, where apache would check for an internal IP, then send them on to reset.school.edu. External users would have to fill out the captcha before being sent to reset.school.eduIs this possible using {REMOTE_ADDR} in apache? Something like:#gateway.school.edu virtual hostRewriteCond %{REMOTE_ADDR} ^192.*RewriteRule .* reset.school.eduIs there another approach I could take to accomplish this, or would a rewrite be the best way? Syntactically, how do I define the IP ranges?
Apache Redirect for Internal Traffic Only
redirects;apache;mod rewrite;url rewriting;apache2
Try this:#gateway.school.edu virtual hostRewriteCond %{REMOTE_ADDR} ^10\.(.*)$ [OR]RewriteCond %{REMOTE_ADDR} ^172\.(.*)$ [OR]RewriteCond %{REMOTE_ADDR} ^192\.(.*)$RewriteRule .* reset.school.edu [R=301,L]The .* is a wildcard. The \ escapes the . which anchors the match allowing it to be taken literally. The () may not be necessary- it is usually used to capture the value of the regular expression match into a variable. You may be able to remove them, but I left them for this example for the sake of readability. The ^ matches the beginning of the line. The $ matches the end of the line. The [OR] is obvious. The [R=301,L] is a redirect 301 and last.