views:

125

answers:

2

I have a Ruby on Rails app running on 12001. I am currently redirecting a subdomain to 127.0.0.1:12001 using some ReWriteCond detection. Now I want to redirect my subdirectory to that rails app.

http[s]://domain.com/redmine

to

127.0.0.1:12001

The current rules apply REQUEST_URI to the above rails path, but I need to strip "/redmine" from the front of REQUEST_URI...

Any ideas?

A: 

You can do this without mod_rewrite.

Redirect Permanent /redmine http://127.0.0.1:12001

This should do what you want.

Dietrich Epp
I need rewrite. This is a production environment. Redirecting to 127.0.0.1 redirects to the end-user's machine, not my web server's ruby server.
Eric Cope
You said, "I want to redirect". Do you really want to use ReverseProxy instead?
Dietrich Epp
A: 
RewriteRule ^/redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

If the rule is placed in the Directory directive, then:

RewriteRule ^redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

The parameters at the end:

  • [QSA] appends the query string (up to you);
  • [L] makes it the last rule

NB /redmine will not be matched by this rule, but I am going off what you tried, only subpaths, e.g. /redmine/abc

Cez