When a site that uses a Cornell sub-domain  (i.e. cen.alumni.edu, homecoming.cornell.edu, etc...) needs to redirect to landing page or child pages, the following steps need to be done.

Step-by-step guide

  1. When the DNS will be pointed to the home page and then needs help to land on the CEN page. There are two options for the code. If you simply want to have the page go to default landing page (homecoming.cornell.edu), use option 1 and you’re done. If sub-page pointing is being used (CEN.cornell.edu), use option 2.
    1. Option 1 – default landing page (goes only to the landing page, not to any child pages)
      1. if (

        isset( $_ENV['PANTHEON_ENVIRONMENT'] ) &&

        ( 'live' === $_ENV['PANTHEON_ENVIRONMENT'] ) &&

        isset( $_ENV['PANTHEON_SITE_NAME'] ) &&

        ( 'cornell-alumni' === $_ENV['PANTHEON_SITE_NAME'] ) &&

        isset( $_SERVER['HTTP_HOST'] ) &&

        ( false !== strpos( $_SERVER['HTTP_HOST'], 'cen.cornell.edu' ) ) &&

        php_sapi_name() != 'cli'

         

        ) {

         

        $new_url = 'https://alumni.cornell.edu/connect/networking/cen/';

        header( 'HTTP/1.0 301 Moved Permanently' );

        header( 'Location: ' . $new_url );

        exit();

        }

    2. Option 2 – child page specified by url
      1. if (
        isset( $_ENV['PANTHEON_ENVIRONMENT'] ) &&
        ( 'live' === $_ENV['PANTHEON_ENVIRONMENT'] ) &&
        isset( $_ENV['PANTHEON_SITE_NAME'] ) &&
        ( 'cornell-alumni' === $_ENV['PANTHEON_SITE_NAME'] ) &&
        isset( $_SERVER['HTTP_HOST'] ) &&
        ( false !== strpos( $_SERVER['HTTP_HOST'], 'cen.cornell.edu' ) ) &&
        php_sapi_name() != 'cli'

        ) {

        $new_url = 'https://alumni.cornell.edu/connect/networking/cen/';
        header( 'HTTP/1.0 301 Moved Permanently' );
        header( 'Location: ' . $new_url . $_SERVER['REQUEST_URI'] );
        exit();
        }

    3. Make the above changes in the "cornell-alumni/config/environments/pantheon.php"
  2. If the traffic comes from a new domain/subdomain, connect the domain in the Pantheon dashboard:
  3.  Add redirects in "Safe Redirects Manager" – (NOTE: This step is only for using the "Option 2" code above)
    1. Different types of redirects (only applies with Option 2 code):
      1. Going to the landing page:
      2. Go to a specific child page
      3. Using the search feature in alumni.cornell.edu
      4. Non-AAD URLS

  4. Request DNS change
    1. Work directly with Hostmaster@cornell.edu to schedule. Once you enter the domain info into the Pantheon dashboard for the Live/Production area, it will give you the new destination DNS info from there and send that along to Hostmaster.

TEST AREA:

You can request a test dns/redirects by requesting a staging dns pointing to a test instance 

That DNS can change to point to the Pantheon Test instance (you need to update the Pantheon dashboard to include the new domains), and then test there before making the DNS switch for CEN prod.

 

 

 

 

1.       When the DNS will be pointed to the home page and then needs help to land on the CEN page.

a.       There are two options for the code. If you simply want to have the page go to default landing page (homecoming.cornell.edu), use option 1 and you’re done. If subpage pointing is being used (CEN.cornell.edu), use option 2.

                                                               i.      Option 1 – default landing page (goes only to the landing page, not to any child pages)

if (

isset( $_ENV['PANTHEON_ENVIRONMENT'] ) &&

( 'live' === $_ENV['PANTHEON_ENVIRONMENT'] ) &&

isset( $_ENV['PANTHEON_SITE_NAME'] ) &&

( 'cornell-alumni' === $_ENV['PANTHEON_SITE_NAME'] ) &&

isset( $_SERVER['HTTP_HOST'] ) &&

( false !== strpos( $_SERVER['HTTP_HOST'], 'cen.cornell.edu' ) ) &&

php_sapi_name() != 'cli'

 

) {

 

$new_url = 'https://alumni.cornell.edu/connect/networking/cen/';

header( 'HTTP/1.0 301 Moved Permanently' );

header( 'Location: ' . $new_url );

exit();

}

 

                                                             ii.      Option 2 – child page specified by url

if (
isset( $_ENV['PANTHEON_ENVIRONMENT'] ) &&
( 'live' === $_ENV['PANTHEON_ENVIRONMENT'] ) &&
isset( $_ENV['PANTHEON_SITE_NAME'] ) &&
( 'cornell-alumni' === $_ENV['PANTHEON_SITE_NAME'] ) &&
isset( $_SERVER['HTTP_HOST'] ) &&
( false !== strpos( $_SERVER['HTTP_HOST'], 'cen.cornell.edu' ) ) &&
php_sapi_name() != 'cli'

) {

$new_url = 'https://alumni.cornell.edu/connect/networking/cen/';
header( 'HTTP/1.0 301 Moved Permanently' );
header( 'Location: ' . $new_url . $_SERVER['REQUEST_URI'] );
exit();
}

b.       Make the above changes in the “cornell-alumni/config/environments/pantheon.php”

2.       Add redirects in “Safe Redirects Manager”

a.       Different types of redirects:

                                                               i.      Going to the landing page (using the second coding option):

 

                                                             ii.      Go to a specific child page:

 

 

                                                           iii.      Using the search feature in alumni.cornell.edu:

 

                                                           iv.      Non-AAD urls:

 

3.       Request DNS change

a.       work directly with Hostmaster@cornell.edu to schedule. Once you enter the domain info into the Pantheon dashboard for the Live/Production area, it will give you the new destination DNS info from there and send that along to Hostmaster.

b.       TEST Area: There is also a test url you can use on the Test env if you want before doing production changes: 

                                                               i.      https://cen-stage.hosting.cornell.edu/

                                                             ii.      That DNS can change to point to the Pantheon Test instance (you need to update the Pantheon dashboard to include the new domains), and then test there before making the DNS switch for CEN prod.