how do I redirect from a subdirectory to another directory, but strip off the original subdirectory from the URI using mod_rewrite
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...开发者_StackOverflow
Any ideas?
You can do this without mod_rewrite.
Redirect Permanent /redmine http://127.0.0.1:12001
This should do what you want.
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
精彩评论