I searched web for several days but didn't found solution for my problem. Lets say I have a web application (written in Ruby on Rails with apache passenger mod) running at mydomain.com
All I need is to rewrite users pointing to www.domain2.com to domain2.mydomain.com leaving users browser at www.domain2.com but "catch" subdomain string in my application.
Thats my apache config (vhost domain2.com ) for that job:
RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?domain2.com$ RewriteRule ^(.*) http://domain2.mydomain.com$1 [P,R=301,L]
but it's not working. Everything works (it points to my app and so on) but application catches "www" subdomain string (that is on users browser) but not expected one.
RewriteRule without "P" flag works just fine. My app catches right domain name (domain2), but URL changes in users browser (to domain2.mydomain.com)
What should I do. Maybe it's impossible to do such trick?
Thanks a lot for an answer.