: Apache Redirect for Internal Traffic Only 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
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.edu
Is this possible using {REMOTE_ADDR} in apache? Something like:
#gateway .school.edu virtual host
RewriteCond %{REMOTE_ADDR} ^192.*
RewriteRule .* reset.school.edu
Is 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?
More posts by @XinRu657
1 Comments
Sorted by latest first Latest Oldest Best
Try this:
#gateway .school.edu virtual host
RewriteCond %{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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.