I want to use Multi-Domains in Subfolders, not Subdomains

I use WordPress(Multi User) by Subfolders.
And, I want to use Multi-Domains with Domain-Mapping.
Is it possible?
I tried this, But I could not use.
I used dm_sunrise.php(rename to sunrise.php), But Multi-Domains and Domain-Mapping was not worked.

dm_sunrise.php is only for Subdomains ?
Or, I think I mistake settings of DNS .
How to set DNS with using by subfolders?

Please Help !!

  • chiga

    Hi Ulrich.

    OK, I give you more details. Sorry, My English is not good.

    I can add dmains in admin panel( Super Admin > Multi-Domains ).
    And I can make a blog by multi-domains.
    But This blog is not shown. It is shown only white screen.

    After I set a dm_sunrise.php(rename to sunrise .php) to wp-content, I can not use Domain-Mapping Plugin.
    If I try to show a blog( domain-mapping ) , It is shown a root site.

    It is even easier to setup (since you don't have to add wildcard dns).

    Yes, I dont add wildcard dns.
    I add only DNS "A" record. Is this right ?

  • chiga

    OH, Sorry !!! Sorry !!!
    I mistake spell of domain added.
    I add domain ( right spell ) again.
    It is shown a blog ( using multi-domain )
    Very Sorry Sorry !!!!!

    But There are one problem.
    If I use dm_sunrise.php, It is not shown a blog (domain mapping).
    It is show root site ( redirect to root site ).
    So, I try to use sunrise.php of Domain-Mapping Plugin. ( Is This right ? )
    A blog (domain mapping) is shown.

  • chiga

    This is my dm_sunrise.php of multi-domains-1.0.9 .

    <?php
    
    if ( defined( 'COOKIE_DOMAIN' ) )
    	die( 'The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that define() line.' );
    
    // Compatibility mode
    define('DM_COMPATIBILITY', 'yes');
    
    // domain mapping plugin to handle VHOST and non VHOST installation
    global $wpdb;
    
    // No if statement needed as the code was the same for both VHOST and non VHOST installations
    if(defined('DM_COMPATIBILITY')) {
    	$wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
    } else {
    	$wpdb->dmtable = $wpdb->base_prefix . 'domain_map';
    }
    
    $wpdb->suppress_errors();
    
    $using_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );
    
    $mapped_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->dmtable} WHERE domain = '{$using_domain}' LIMIT 1 /* domain mapping */" );
    
    $wpdb->suppress_errors( false );
    
    if ( !$mapped_id && ( preg_replace( "/^www\./", "", DOMAIN_CURRENT_SITE ) !== preg_replace( "/^www\./", "", $using_domain ) ) ) {
    	$md_domains = unserialize( $wpdb->get_var( "SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = 'md_domains' AND site_id = 1" ) );
    
    	if( $_SERVER['REQUEST_URI'] == '/' ) {
    		foreach ( $md_domains as $domain ) {
    
    			if( $_SERVER['HTTP_HOST'] == strtolower( $domain['domain_name'] ) ) {
    				$location = 'http://' . DOMAIN_CURRENT_SITE;
    
    				if ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) == true || strpos( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) == true ) {
    					header( "Refresh: 0;url=$location ");
    				} else {
    					if ( php_sapi_name() != 'cgi-fcgi' )
    						status_header($status); // This causes problems on IIS and some FastCGI setups
    					header( "Location: $location", true, 301 );
    				}
    
    				die;
    			}
    
    		}
    	}
    
    	foreach( $md_domains as $domain ) {
    		if ( preg_match( '|' . strtolower( $domain['domain_name'] ) . '$|', preg_replace( "/^www\./", "", $using_domain ) ) ) {
    			define( 'COOKIE_DOMAIN', '.' . strtolower( $domain['domain_name'] ) );
    			break;
    		}
    	}
    }
    
    if( $mapped_id ) {
    	$current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d LIMIT 1 /* domain mapping */", $mapped_id ) );
    	$current_blog->domain = $_SERVER[ 'HTTP_HOST' ];
    
    	$blog_id = $mapped_id;
    	$site_id = $current_blog->site_id;
    
    	define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );
    
    	$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d /* domain mapping */", $current_blog->site_id ) );
    
    	$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s /* domain mapping */", $current_site->domain, $current_site->path ) );
    
    	$current_blog->path = $current_site->path;
    
    	define( 'DOMAIN_MAPPING', 1 );
    
    	// Added for belt and braces
    	if ( !defined('WP_CONTENT_URL') ) {
    		$protocol = ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
    		define( 'WP_CONTENT_URL', $protocol . $current_blog->domain . $current_blog->path . 'wp-content'); // full url - WP_CONTENT_DIR is defined further up
    	}
    
    }