LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 04-29-2007, 05:51 AM   #1
jika
LQ Newbie
 
Registered: May 2005
Posts: 4

Rep: Reputation: 0
Apache mod_rewrite RewriteCond infinite loop problem


Hi,

short description of situation:

I have a reverse proxy built from Apache 2.2.3 with load balancing using mod_balancer. For security reasons I need to redirect all locations different from /balancer (Load Balancer web interface) to server root (/).

I made a following piece of code which should do the job but it creates an infnite loop instead:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/balancer$
RewriteRule ^/(.*)$ / [R,L]


When I remove the exclamation from the second line, it works, but does exactly opposite of desired - rewrites only requests for /balancer, everything else is untouched. I suppose misconfiguration somewhere in negation of second line but I can't find it...

Someone any idea?

Thanks for help!

jika

Last edited by jika; 04-29-2007 at 08:56 AM.
 
Old 04-29-2007, 08:01 AM   #2
zaichik
Member
 
Registered: May 2004
Location: Iowa USA
Distribution: CentOS
Posts: 419

Rep: Reputation: 30
If the request is not /balancer then it gets rewritten to /, which is also not balancer, so it gets rewritten again to / and so on. Throw in another couple rules:
Code:
RewriteEngine On
ReWriteCond %{REQUEST_URI} !^/$
ReWriteCond %{REQUEST_URI} !^$
RewriteCond %{REQUEST_URI} !^/balancer$
RewriteRule ^/(.*)$ / [R,L]
 
Old 05-01-2007, 07:25 AM   #3
jika
LQ Newbie
 
Registered: May 2005
Posts: 4

Original Poster
Rep: Reputation: 0
zaichik, thanks for help. However it is not working exactly as expected - all requests are rewritten to / - it is impossible to reach /balancer. This is caused by the first line of your code - all requests match it.
Finally I made it a little different way, which is not 100% I wanted at the beginning, but it is satisfactory enough for me:
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/balancer$
RewriteRule ^/(.*)$ /index.html [L]
All requests except those targeting /balancer are redirected to /index.html.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Infinite Loop ewt3y Programming 3 08-16-2005 09:48 AM
Java Stopping an Infinite loop oulevon Programming 3 10-18-2004 10:11 PM
infinite loop beginner_84 Programming 5 08-15-2004 02:32 AM
facing problem in increment operator of set :infinite LOOP ashwinipahuja Programming 0 06-03-2004 12:05 AM
Sendmail build - infinite loop?? kstarks Linux - Software 0 10-02-2003 07:13 AM


All times are GMT -5. The time now is 02:45 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration