tags:

views:

465

answers:

3

Hi, I have a main domain MYDOMAIN.COM

I want to make it easy for me to remember my Google Apps email URL, so I just want to redirect gmail.MYDOMAIN.CCOM to my Google Apps email URL using .htaccess to do a redirect.

How do I do this?

A: 

Assuming Apache, mod_rewrite will allow you to create redirects like this.

Matthew Iselin
+1  A: 

To expand on @Matthew Iselin, this should work in a .htaccess in the directory that represents the root of your subdomain:

RewriteEngine on
RewriteRule ^/(.*) http://wherever.gmail.com/

or whatever the url is.

Without mod_rewrite, you can use mod_alias:

Redirect permanent / http://wherever.gmail.com/

Although, the mod_rewrite solution is "better", it's not enabled on all server. mod_alias however should be.

Matthew Scharley
Does a DNS entry for the machinename "gmail" or "whatever" need to be established for this to work? I mean, you can't just surf to wwwxyzanything.example.com and have it resolve to your "www" hosting, now, can you?
Funka
Sorry, that was meant to be a rhetoric question... The correct comment I should have left should have indicated that you'll also need to have control of (and know how to configure) your domain's DNS record... The example monoxide left suggests that such a setup would exist in a separate root directory on your server. Other approaches might dump you into the same directory...
Funka
Most servers are setup to have seperate directories for each subdomain. In the case you are using a server that isn't, I don't think you'd be asking this question. There is an option to setup a DNS CNAME for gmail.MYDOMAIN.COM -> wherever.gmail.com too, but the question was specifically about doing this in .htaccess
Matthew Scharley
Is there a way I can create it in such a way as not needing to set up a directory in the subdomain? I'm not sure if that works....so I'd like the RewriteRule itself, if possible, to read the subdomain...for expediency I changed the DNS cname.
Angela
Like I said in my comment, if you have access to your domain name's DNS then you can simply add a CNAME to google apps... but not everyone does, and you asked for an answer inside apache, which is a perfectly valid question too :)
Matthew Scharley
A: 

A slightly indirect answer...

Why don't you just setup DNS for gmail.mydomain.com and instruct Google Apps (via admin panel) to respond to that subdomain? The instructions are right in the admin panel, and very simple to follow.

It's a snap.

gahooa
okay, i've done it this, way, thanks.
Angela