I use wordpress multisite and domain mapping. My

Hello, I use wordpress multisite and domain mapping.
My sub-domain( 1.example.com )mapped to this ( mydomain.com )domain name.
My question is,
mydomain.com/contact this page only i want redirect to 1.examble.com/contact ( original sub domain )
How this can be done?
i already asked this question multisite category. But still i not get any useful answers.
Anyone please help.
https://premium.wpmudev.org/forums/topic/i-use-wordpress-multisite-and-domain-mapping-my

  • Vaughan

    Hi @raja,

    I haven't tested this, but there's some new functionality in DM for use with marketpress.

    It might not actually work for your particular scenario though.

    But can you try adding the following to a mu-plugin

    Create a file called functions.php

    Then add the following to it

    <?php
    function do_not_map_domain() {
        global $post;
    
        $slug_array = array('contact');
    
        $slug = get_post( $post )->post_name;
        if(in_array($slug, $slug_array)) {
            return true;
        }
    }
    
    add_filter( "dm_prevent_redirection_for_ssl", 'do_not_map_domain', 999, 1);

    then copy that to wp-content/mu-plugins/

    I haven't tried this at all, so it may not work.

    If you want to add multiple pages, then add the pages to the slug_array, seperating each with a comma like so

    array('contact', 'page2', 'page3')

    you will then need to add the following to your htaccess

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.mappeddomain\.com/contact$
    RewriteRule (.*) http://sub.olddomain.com/$1 [R=301,L]

    you'll need to add a Cond & Rule for each page though

    replace mappeddomain with the mapped domain url & the sub.olddomain.com with the original subdomain.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.