# Redirect multiple domains to a single domain

**URL:** <https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291>\
**Category:** help\
**Created:** [January 4, 2017, 10:59pm UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291 "2017-01-04T22:59:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebfjohnson](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@ebfjohnson](https://discourse.mitmproxy.org/u/ebfjohnson)\
**Post date:** [January 4, 2017, 10:59pm UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291/1 "2017-01-04T22:59:36Z")

</div>

I looked around for several hours and couldn’t find a solution to my problem.

I want to redirect [webmail.abc.com](http://webmail.abc.com) to [abccom.xyz.com](http://abccom.xyz.com) where [webmail.abc.com](http://webmail.abc.com) resolves to my mitmproxy server and [abccom.xyz.com](http://abccom.xyz.com) resolves to a email client login page I created that replaces my hosting partners webmail page.

i.e. this is a server to server redirection one might use apache vhosts but I would like to use mitm instead.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![ebfjohnson](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@ebfjohnson](https://discourse.mitmproxy.org/u/ebfjohnson)\
**Post date:** [January 5, 2017, 4:30pm UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291/2 "2017-01-05T16:30:39Z")

</div>

I have tried so many different tests I didnt post any of them because I thought it would be more confusing. The most recent thing I tried is:  
mitmproxy -R [http://webmail.abc.com](http://webmail.abc.com) -p 80 --replace :~q:abc:xyz --replace :~q:webmail:abccom

There is never a response with the replacements so it times out.

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [January 7, 2017, 8:19pm UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291/3 "2017-01-07T20:19:20Z")

</div>

How should that redirection look like? Do you want to display the contents of `abccom.xyz.com` at `webmail.abc.com`? Do That could be tricky: [http://docs.mitmproxy.org/en/stable/modes.html#reverse-proxy](http://docs.mitmproxy.org/en/stable/modes.html#reverse-proxy) Do you want to send a HTTP 30x redirect? What exactly are you trying to accomplish?

---

<div class="post-metadata">

**Author:** ![ebfjohnson](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@ebfjohnson](https://discourse.mitmproxy.org/u/ebfjohnson)\
**Post date:** [January 11, 2017, 2:17am UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291/4 "2017-01-11T02:17:06Z")

</div>

Thanks for the help.

I am essentially redirecting all port 80 requests for webmail to a custom login screen by domain.

I was able to get mitmproxy working after modifying the redirect\_request.py and a lot of trial and error.

Do you have any startup script examples of running mitmdump for ubuntu 16.04?

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [January 11, 2017, 12:41pm UTC](https://discourse.mitmproxy.org/t/redirect-multiple-domains-to-a-single-domain/291/5 "2017-01-11T12:41:30Z")

</div>

We don’t, but that’s a rather non-mitmproxy-specific problem, so you should find a lot of examples for writing systemd service files on Google/StackOverflow. 🙂
