404 When Previewing Pages or Post With Mapped Domain

I can't get domain mapping to work when previewing pages or post it always returns a 404 File Not Found error

The mapped domain URL looks like this http://example.com/?p=76&preview=true

Note: I've got ssl for the admin area enabled not sure if this has anything to do with it.

  • aristath
    • Recruit

    Could you please verify that the domains you are talking about have their DNS entries properly configured?

    It would be useful if you could post here the following info:

    The main site's URL
    The domains you're trying to use with the domain-mapping plugin.

    When you do, I'll be able to ping them and hopefully find out the error.

    Awaiting your reply,

  • aristath
    • Recruit

    There's probably something wrong with your DNS enries...

    I tried pinging your site and this is what I got:

    ping caribonix.com
    PING caribonix.com ( 56(84) bytes of data.
    --- caribonix.com ping statistics ---
    285 packets transmitted, 0 received, 100% packet loss, time 284696ms

    Same thing for the other domain.

    Then tried it on http://network-tools.com/default.asp?prog=express&host=caribonix.com
    and I got a bunch of "Timed Out" errors.

    I suggest you resolve these issues first, otherwise the Domain Mapping plugin will not be able to properly function!


  • northgate
    • The Incredible Code Injector

    oh I forgot to mention I run on an Amazon AWS environment the port for pinging is not open by default.

    hence the timeouts

    is ICMP ECHO required for domain mapping to work?

    The website and subsites are all functioning properly would that be the case if there were DNS enries issues?

  • Paul Barthmaier
    • Code Wrangler

    Hi there,

    You've still got the www in there. I see that your DNS entries are correct. Check your wp-config and make sure it doesn't have the www in the domain. The check your Site URL and Home in either Network settings or the wp-options table. It could be that you'll need to clean up the database with a Search and Replace looking for http://www.caribonix.com and changing to caribonix.com.


    Don't like native styling of Comments Plus? No prob: http://marker.to/YQ7EuI

  • northgate
    • The Incredible Code Injector

    OK. correct me if I'm wrong but you're saying because the main site has www it is causing domain mapping not to function properly on the sub sites in order to allow me to preview a sub site page or post?

    I thought all sub sites were some what independent of the mail site.

    If a sub site is not mapped I can preview it like normal I can also preview the main site which is not mapped but has www with no problems.

    I've got https:// enabled for the admin not sure if this is the cause of the problem for example


    However I change the https to http on click via jquery (when the link is clicked) to avoid getting a browser ssl warning on the mapped domain

    // Controls changing URL protocal from https:// to http:// on click
    	jQuery('#wp-admin-bar-view-site a.ab-item, #wp-admin-bar-view a.ab-item, .updated p a, .welcome-view-site, .view a').click(function() {
    		// Get link href attribute
    		var getsitLink = jQuery(this).attr('href');
    		//Check if link protocal is https:// If yes change to http://
    		if (getsitLink.indexOf('https:') > -1) {
    			newsitLink = getsitLink.replace('https:', 'http:');
                jQuery(this).attr('href', newsitLink);
            }//End IF

    so the domain becomes


    here is the example of the preview link


    Note: this jquery https to http on click is applied to none mapped domains and works perfectly

  • aristath
    • Recruit

    Hello again @northgate, I hope you're well today!

    The first thing you should check is that he your sunrise.php file is updated as well. I fogot to update it once and it took me hours to figure it out.
    I suggest you also take a look at this thread as it looks pretty similar to your issue:

    I am not sure the www matters when used on the main site, but at this point I don't know how to debug this issue. So I have already notified the plugin developer about this requesting his feedback.

    In the meantime, please check your sunrise.php file.


  • northgate
    • The Incredible Code Injector

    ok as requested here it is

    /** Enable W3 Total Cache */
    define('WP_CACHE', true); // Added by W3 Total Cache
    /** Enable W3 Total Cache */
    // Added by W3 Total Cache
    * The base configurations of the WordPress.
    * This file has the following configurations: MySQL settings, Table Prefix,
    * Secret Keys, WordPress Language, and ABSPATH. You can find more information
    * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
    * wp-config.php} Codex page. You can get the MySQL settings from your web host.
    * This file is used by the wp-config.php creation script during the
    * installation. You don't have to use the web site, you can just copy this file
    * to "wp-config.php" and fill in the values.
    * @package WordPress
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    /** MySQL database username */
    /** MySQL database password */
    /** MySQL hostname */
    /** Database Charset to use in creating database tables. */
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    * Authentication Unique Keys and Salts.
    * Change these to different unique phrases!
    * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
    * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
    * @since 2.6.0
    * WordPress Database Table prefix.
    * You can have multiple installations in one database if you give each a unique
    * prefix. Only numbers, letters, and underscores please!
    * WordPress Localized Language, defaults to English.
    * Change this to localize WordPress. A corresponding MO file for the chosen
    * language must be installed to wp-content/languages. For example, install
    * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
    * language support.
    define('WPLANG', '');
    * For developers: WordPress debugging mode.
    * Change this to true to enable the display of notices during development.
    * It is strongly recommended that plugin and theme developers use WP_DEBUG
    * in their development environments.
    define('WP_DEBUG', false);
    /* Specify the Number of Post Revisions */
    define('WP_POST_REVISIONS', 3);
    /* Enable Multisite / Network Ability */
    define('WP_ALLOW_MULTISITE', true);
    /* Empty Trash */
    define('EMPTY_TRASH_DAYS', 15 );  // 30 days
    /*Enabling the Network*/
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', 'www.example.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    /* Load Domain Mapping*/
    define( 'SUNRISE', 'on' );
    /* Redirect visitors to if they visit a non-existent site */
    define( 'NOBLOGREDIRECT', 'http://www.example.com' );
    /* Get Host */
    $host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']);
    /* Allow Site-by-Site SEO Control*/
    define( 'WDS_SITEWIDE', false );
    * WordPress SMTP server
    /* That's all, stop editing! Happy blogging. */
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

    Note: I updated to the beta still no solution

  • Barry
    • DEV MAN’s Mascot

    Yeah, there are a few in there that you should remove. If you grab the beta and go to the domain mapping settings page (in the network admin area) then it will notify you of the exact lines.

    But they are the ones that look like this:

    define('DOMAIN_CURRENT_SITE', 'www.example.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
  • Barry
    • DEV MAN’s Mascot

    Would removing the lines stated have any effect on my main site?

    No they seem to have been added to bypass some other code that actually looks at the domain visited and finds the id of the site from that (whether to reduce database queries or processing I don't know), so it has been found to stop domain mapping working correctly on a few installs as the domain is set in the define instead.

    Those of us with older installs have never had these lines in our wp-config.php files.

  • northgate
    • The Incredible Code Injector


    I've been doing some additional testing what I've notice is if "https:" is enabled on the back end then then the mapped domain generates the 404 when "previewing" the page or post.

    If "https:" is not enabled on the back-end then "previewing" the page or post works fine

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.