Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

Solved: How to redirect a subdomain to a port in Apache?


(!)

Soundy's Avatar
Computer Specs
Member with 1,829 posts.
THREAD STARTER
 
Join Date: Feb 2006
Location: The Pitt, BC
Experience: Omnigeek
11-Dec-2009, 02:09 PM #1
Solved: How to redirect a subdomain to a port in Apache?
Quite simply: I'm running mail and webserver on the same system... the mailserver has its own webmail interface on port xxxx. I want, for example, 'http://webmail.mydomain.com' to redirect to "http://mydomain.com:xxxx". How would I do this in Apache 2.2?
ehymel's Avatar
ehymel   (Ernie) ehymel is offline
Member with 695 posts.
 
Join Date: Aug 2007
Location: Texas
12-Dec-2009, 01:15 PM #2
Quote:
Originally Posted by Soundy View Post
Quite simply: I'm running mail and webserver on the same system... the mailserver has its own webmail interface on port xxxx. I want, for example, 'http://webmail.mydomain.com' to redirect to "http://mydomain.com:xxxx". How would I do this in Apache 2.2?
In the apache config file (or within one of the conf.d/*.conf files, use the Redirect command.

Code:
Redirect permanent / http://mydomain.com:xxxx
The 'permanent' designation is optional.

Another good solution if you want *ALL* requests for a page within the the default port 80 request to be redirected to the same request within another port, something like this could be used:

Code:
RedirectMatch permanent /(.*) http://mydomain.com:xxxx/$1
Hope this helps.
Soundy's Avatar
Computer Specs
Member with 1,829 posts.
THREAD STARTER
 
Join Date: Feb 2006
Location: The Pitt, BC
Experience: Omnigeek
13-Dec-2009, 09:20 PM #3
Hmmm that's redirecting EVERYTHING to port xxxx - I don't want mydomain.com or www.mydomain.com to redirect, just webmail.mydomain.com
ehymel's Avatar
ehymel   (Ernie) ehymel is offline
Member with 695 posts.
 
Join Date: Aug 2007
Location: Texas
15-Dec-2009, 07:40 PM #4
I guess I should have been more specific.

The Redirect statements should go within your <VirtualHost> section for the subdomain you are wanting to redirect.

For example, I use the following section to redirect all port 80 requests to a SSL connection on 2 different web-based email domains that I maintain, along with a snippet to show how I use a permanent redirect. Hopefully this will show some examples of how I use these:

Code:
<VirtualHost *:80>
    ServerName mail.e-medico.com
    ServerAlias group.e-medico.com
    RedirectPermanent / https://group.e-medico.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName mail.setexonc.com
    RedirectPermanent / https://mail.setexonc.com/
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/sites.clients/setexonc.com/www
    ServerName setexonc.com
    ServerAlias www.setexonc.com

    RedirectMatch /treatment/(.*).htm$ http://www.rtanswers.org/treatment/$1.htm
    RedirectMatch /index.html /
    RedirectPermanent /mail https://mail.setexonc.com/
    ErrorDocument 404 /error.php
    <Directory /var/www/sites.clients/setexonc.com/>
        allow from all
        order allow,deny
    </Directory>
</VirtualHost>
Soundy's Avatar
Computer Specs
Member with 1,829 posts.
THREAD STARTER
 
Join Date: Feb 2006
Location: The Pitt, BC
Experience: Omnigeek
16-Dec-2009, 01:48 AM #5
Oooooh I see, got it, thanks.

Works perfectly now!
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑