Redirect to new domain and preserve username

Posted by David Brown on Server Fault See other posts from Server Fault or by David Brown
Published on 2013-10-28T20:21:55Z Indexed on 2013/10/28 21:56 UTC
Read the original article Hit count: 267

Filed under:
|

I recently switched to a new domain for a version control server I run. The server is usually accessed with a username included in the url such as https://[email protected]/some/stuff. I want to redirect requests to the old domain to the new domain and preserve everything else in the url (including the username). So the former url would be redirected to https://[email protected]/some/stuff. Currently I have the following rewrite condition and rule:

RewriteCond %{HTTP_HOST} sub\.olddomain\.com 
RewriteRule (.*) https://sub.newdomain.net$1 [R=301,L]

This works except it drops the userinfo part of the URL. Is there a way I can preserve the user info?

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-rewrite