httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Isenhower, Dave" <dave.isenho...@siemens.com>
Subject RE: [users@httpd] redirect based on internal or external IP
Date Wed, 03 Jul 2013 17:51:36 GMT
Exclude "www.site.com" from your RewriteRule.  If you need to use the domain, you'd have to
prefix it with "http://".  Try this:

RewriteCond %{REMOTE_ADDR} ^1.1.1.1
RewriteCond %{REQUEST_URI} !^/internal
RewriteRule ^(.*)$     /internal [R=301,L]

RewriteCond %{REMOTE_ADDR} ^2.2.2.2
RewriteCond %{REQUEST_URI} !^/external
RewriteRule ^(.*)$    /external [R=301,L]

-Dave

From: Clark, Kim [mailto:kclark@carlsonwagonlit.com]
Sent: Wednesday, July 03, 2013 12:51 PM
To: users@httpd.apache.org
Subject: RE: [users@httpd] redirect based on internal or external IP

I am receiving the following error with the below configuration
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

  RewriteCond %{REMOTE_ADDR} ^1.1.1.1
  RewriteCond %{REQUEST_URI} !^/internal
 RewriteRule ^(.*)$ www.site.com/internal<http://www.site.com/internal> [R=301,L]

The only other redirects I have in this virtualhost are for opencms.  I am not sure why I
am receiving the error "TOO_MANY_REDIRECTS"
ProxyPass         /opencms/       http://172.30.72.15:8080/opencms/
    RedirectPermanent /opencms/       http://careers.carlsonwagonlit.com/


    ProxyPass /export http:// 7.7.7.7:8080/export
    ProxyPassReverse /export http:// 7.7.7.78080/export

    ProxyPass /resources http:// 7.7.7.7:8080/resources
    ProxyPassReverse /resources http: 7.7.7.78080/resources

    ProxyPass   /  http:// 7.7.7.7:8080/opencms/
    ProxyPassReverse /  http:// 7.7.7.7:8080/opencms/


[CWT2]

Kim Clark | Sr. Technical Analyst, Technology
Carlson Wagonlit Travel
phone +1 763 212 3092 | fax +1 763 212 3200
kclark@carlsonwagonlit.com<mailto:fvandellen@carlsonwagonlit.com?subject=Dear%20Fred>|
 www.carlsonwagonlit.com<http://www.carlsonwagonlit.com/>


phone +01 763-212-3092 | fax +01 763-212-3200
With offices in more than 150 countries and territories, Carlson Wagonlit Travel deploys the
right people, processes, technologies and skills to consistently deliver effective travel
management and bottom-line results.

[cid:image002.png@01CC0AA4.34510120]<http://www.cwtsavvytraveler.com/>

[cid:image003.png@01CC0AA4.34510120]<http://www.twitter.com/CWTNorthAmerica>

[cid:image004.png@01CC0AA4.34510120]<http://www.facebook.com/pages/CWT-Savvy-Traveler/191418547541327#!/pages/CWT-Savvy-Traveler/191418547541327>



From: Macks, Aaron [mailto:amacks@harvardbusiness.org]
Sent: Monday, July 01, 2013 4:05 PM
To: <users@httpd.apache.org<mailto:users@httpd.apache.org>>
Cc: users@httpd.apache.org<mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] redirect based on internal or external IP

The way I would handle this is adding a second rewritecond to each stanza, looking at REQUEST_URI
to make sure that the target path is not there, eg
  RewriteCond %{REMOTE_ADDR} ^1.1.1.1
  RewriteCond %{REQUEST_URI} !^/internal
 RewriteRule ^(.*)$ www.site.com/internal<http://www.site.com/internal> [R=301,L]


A
________
Aaron Macks
amacks@harvardbusiness.org<mailto:amacks@harvardbusiness.org>

On Jul 1, 2013, at 3:33 PM, "Clark, Kim" <kclark@carlsonwagonlit.com<mailto:kclark@carlsonwagonlit.com>>
wrote:
I am new to apache, so forgive me if this is a beginner questions.

I am trying to redirect request to apache based on the IP address.  Depending on where the
request originates from, the request will either have a external or internal IP address. 
External will be redirected to the external site, internal will be redirected to the internal
site.

Request to www.site.com<http://www.site.com> will be evaluated based on the IP address.
Then redirected to either www.site.com/external<http://www.site.com/external> or www.site.com/internal<http://www.site.com/internal>.
 I am able to accomplish this with the following.

         RewriteCond %{REMOTE_ADDR} ^1.1.1.1
         RewriteRule ^(.*)$ www.site.com/internal<http://www.site.com/internal> [R=301,L]


         RewriteCond %{REMOTE_ADDR} ^2.2.2.2
         RewriteRule ^(.*)$ www.site.com/external<http://www.site.com/external> [R=301,L]

The problem I am running into is that this is in a loop.  Every request will be evaluated
and redirected.  If possible, I need a way to redirect once, then let other request (www.site.com/external/a/b/c<http://www.site.com/external/a/b/c>
 or www.site.com/internal/x/y/z<http://www.site.com/internal/x/y/z> )not be evaluated
and then redirected

Any suggestion or help would be greatly appreciated.





Mime
View raw message