Using 2 URL’s for WordPress

You can define the URLs by constants added in your wp-config.php.

I suppose you already set up your System in the way that both domains point to the same WordPress installation. Now the only thing you need to check is which Domain is actually used.

Your WordPress installation contains the first URL in the database, let’s call it http://www.external.com, and you want to use the URL http://www.internal.com.

First, check if internal is used, and afterwards tell WordPress to use the alternative URL.

if ( strpos( $_SERVER['HTTP_HOST'], 'internal' ) > 0 ) {

    define('WP_SITEURL', 'http://www.internal.com');
    define('WP_HOME', 'http://www.internal.com');

}

Please be aware of duplicate content etc.

You can also use the constants to display different content for each domain (if internal should have different information).

To replace the Urls in the Content, you can use a simple filter replacing them:

function f711_change_hard_url( $content ) {

    return str_replace( 'http://www.external.com', WP_SITEURL, $content );

}
add_filter( 'the_content', 'f711_change_hard_url', 1000 );