Silent redirect problems with mod_rewrite (and mod_proxy)

Using mod_rewrite to handle various content issues

Silent redirect problems with mod_rewrite (and mod_proxy)

Postby independence » Sun Sep 24, 2006 4:27 am

Hi, have two servers. One is using mod_proxy and ProxyPass to redirect traffic to the other one. Now I want to use mod_rewrite on the first server to rewrite some URLs before they are sent to the second server.

These are my rules so far:
Rewrite:
RewriteCond %{HTTP_HOST} ^([^\.]+)\.blinkenshell\.org$ [NC]
RewriteRule ^(.*)$ http://blinkenshell.org/~%1$1 [L]

Proxy pass:
ProxyPass / http://192.168.1.12:8080/
ProxyPassReverse / http://192.168.1.12:8080/


This works fine. But there is a problem. I want to make the redirect silent, so I rewrite the rewrite rule to:
RewriteRule ^(.*)$ /~%1$1 [L]

And poof, everythings stops working. The rewrite rule doesn't even seems to be processed. I get a request for / on the first server, and the second server doesn't get a request at all.

What is wrong?
independence
 
Posts: 2
Joined: Sun Sep 24, 2006 4:21 am

Postby richardk » Sun Sep 24, 2006 5:57 am

Try:
Code: Select all
RewriteRule ^(.*)$ http://blinkenshell.org/~%1$1 [P,L]


Edit: Or try:
Code: Select all
<VirtualHost *:80>
  ServerName      blinkenshell.org
  ServerAlias www.blinkenshell.org
  ProxyPass        / http://192.168.1.12:8080/
  ProxyPassReverse / http://192.168.1.12:8080/
</VirtualHost>

<VirtualHost *:80>
  ServerName  abc.blinkenshell.org
  ServerAlias   *.blinkenshell.org

  Options +FollowSymLinks
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^([^\.]+)\.blinkenshell\.org$ [NC]
  RewriteRule ^(.*)$ http://192.168.1.12:8080/~%1$1 [P,L]
</VirtualHost>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby independence » Sun Sep 24, 2006 6:48 am

richardk wrote:Try:
Code: Select all
RewriteRule ^(.*)$ http://blinkenshell.org/~%1$1 [P,L]


Edit: Or try:
Code: Select all
<VirtualHost *:80>
  ServerName      blinkenshell.org
  ServerAlias www.blinkenshell.org
  ProxyPass        / http://192.168.1.12:8080/
  ProxyPassReverse / http://192.168.1.12:8080/
</VirtualHost>

<VirtualHost *:80>
  ServerName  abc.blinkenshell.org
  ServerAlias   *.blinkenshell.org

  Options +FollowSymLinks
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^([^\.]+)\.blinkenshell\.org$ [NC]
  RewriteRule ^(.*)$ http://192.168.1.12:8080/~%1$1 [P,L]
</VirtualHost>


The first one seems to work just fine! Thanks!
independence
 
Posts: 2
Joined: Sun Sep 24, 2006 4:21 am


Return to Content

Who is online

Users browsing this forum: No registered users and 1 guest

cron