I have a Problem, that my internal company blog should be visible via 2 URL's. One internal and one external.

Now I would need to rewrite URL's before content is delivered to the browser.

All URL's are in the database and I can't seem to find a place to start rewriting things.

Any clue wich hooks might be useful and what can be done to implement this?


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 );
| improve this answer | |
  • But what about URL's that are hardcoded in links on the posts from assets and all that stuff? Will they be re-written before content get's delivered? – spankmaster79 Mar 5 '14 at 10:05
  • @spankmaster79 i added a method for that. – fischi Mar 5 '14 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.