The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirecting a second subdomain to Google Apps using cPanel

Discussion in 'General Discussion' started by peter.moore, Jul 6, 2009.

  1. peter.moore

    peter.moore Member

    Joined:
    Jul 5, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Since cPanel doesn't allow me to create CNAME records, I created a sub-domain in cPanel (called info.mydomain.com) and then redirected it to the full Google Apps url(ie http://mail.google.com/a/yourdomain.com). It works fine when I type: info.mydomain.com as a url and directs me to Google Apps login.
    However, when I create a second subdomain called 'query.mydomain.com' and again redirect it to the full Google Apps url metioned above, I get the following error when I enter 'query.mydomain.com' as a url:

    "Server error.
    Sorry, you've reached a login page for a domain that isn't using Google Apps. Please check the web address and try again".
    I earlier logged in Google Apps as 'info' and created query@mydomain.com and I've also checked subdomain settings in cPanel ....all seems ok...any ideas. Thanks.
     
  2. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Are you an end user or a server administrator?

    If you have access, just simply edit the DNS zone on the server and add
    in whatever CNAME records you wish and restart your "named" service.

    Code:
    # cd /var/named
    # vi whateverdomain.com.db
      (NOTE: some might use pico instead, I prefer vi)
    
    /\/\/\/  Make whatever zone file changes you wish \/\/\/\/\/
    
    # service named restart
    
    If you want to get fancy, you can edit the zone templates in WHM to add either a wildcard (*) DNS entry
    or automatically setup the specific subdomain for every domain on the server on all accounts you create
    and then create a new virtualhost with that address as a wildcard (subdomainname.*) for the server name
    and then put in a redirect script or mod_rewrite in that new virtualhost. The end result is that every account
    on your server will have a special subdomain under it's own domain that automatically redirects.

    Back when Cpanel was a little crappier about keeping up with MySQLAdmin updates, we used to setup
    our own updated version under http://mysql.*.* for all accounts using this same technique.

    Assuming you didn't mess up something on either your Cpanel side or Google side, I would probably first look into
    exactly how are you initiating your "redirect" because that could effect the referrer sent to Google which is what
    Google uses to identify the source of the directed connection.
     
    #2 Spiral, Jul 6, 2009
    Last edited: Jul 6, 2009
  3. peter.moore

    peter.moore Member

    Joined:
    Jul 5, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Thank you, but here's what I want to do:


    I have created 2 Google Apps user accounts: "info@mydomain.com" and "user@mydomain.com".

    I can enter "info.mydomain.com" at the url address to get to the main Google Apps login page (where I login as 'info',etc).
    I also want to be able to enter "user.mydomain.com" at the url to again get to the main Google Apps login page(to login as 'user' this time).
    What change do I need to make in cPanel, if any?
    (I am using cPanel provided by the domain web host provider).

    Thanks again.
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    That is a little bit clearer ...

    There are several ways to go about doing that. The cleanest would be
    to set that up with a wildcard virtualhost but since it sounds like in
    your last line above that you are an end user and not the server
    administrator, scratch that option unless you can get your provider
    to assist you (and most won't for that). You could setup seperate
    CNAME alias records under your domain for each subdomain instead
    of setting up actual subdomains on your hosting account but again
    since you are not the server administrator or a reseller then that is
    a limited option for you. The next best option that comes to mind
    is to just setup a subdomain under your hosting account and then
    put a redirect script in the subdomain that detects the subdomain
    used to connect and construct a redirect to Google based on that .

    (Using script redirection instead of mod_rewrites gives you a little bit
    more flexibility in terms of any variables or other information you want
    passed on to the redirect site and / or pre-processing before the redirect.
    If you are currently using a flat mod_rewrite redirect with a fixed target,
    that would explain why your second subdomain address doesn't work
    )


    If you want to be a bit fancier, you could have both "info" and "user"
    subdomains call the same site and then have an index script there that
    reads the "$_ENV["HTTP_HOST"]" variable and redirect with different
    information depending on what URL (subdomain) the user used to reach
    the redirect page that takes you on over to Google. That way the
    same redirect information could pass different information or take
    you to different web pages depending on whether someone typed
    "info.domain.com" or "user.domain.com" or some other address even
    though the subdomains themselves may actually all run the same script
    but redirect differently depending on what address the user originally
    used in their browser to call the redirect script page.

    Just a simple example of what I'm talking about:
    Code:
    <?php
        $mydomain = str_replace("www.", "", $_ENV['HTTP_HOST']);
        header("Location: http://mail.google.com/a/{$mydomain}");
    ?>
    
    Side note: HTTP_HOST is a variable that is set within the server
    whenever you connect to a web site that tells all scripts running on
    the web server what address the visitor used to connect to the site.
    If Cpanel where checking that variable right now on my connection,
    the variable would be set to "forums.cpanel.net" as that is the domain
    address I used to connect to this forum community. Checking this
    variable from scripts is an easy way to deliver different web content
    based upon the domain or subdomain the visitor used to connect
     
    #4 Spiral, Jul 7, 2009
    Last edited: Jul 7, 2009
  5. peter.moore

    peter.moore Member

    Joined:
    Jul 5, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    index script suggestion

    Thanks for your reply.

    My web host provider doesn't allow me to setup seperate
    CNAME alias records under my domain for each subdomain, etc.

    So that leaves your 'index script' suggestion.
    I had setup a subdomian "info.domain.com" under my hosting account "domain.com", so that's already been done,
    but I have one question.

    Should I place the code snippet:
    <?php
    $mydomain = str_replace("www.", "", $_ENV['HTTP_HOST']);
    header("Location: http://mail.google.com/a/{$mydomain}");
    ?>

    into my index.html file, or create an new file called index.php and place that in the 'root' directory?
    Thanks again for your time...much appreciated.
     
Loading...

Share This Page