Mapped domain returns /wordpress path for homepage

Hello,

I am using Multisite with sub-directories feature. We have just started using the Domain Mapping plugin to map http://bestafternoonteas.com domain which is originally hosted on https://sales.resdiary.com/afternoon-teas/ amongst a few more sub-site.

My question is why http://bestafternoonteas.com adding http://bestafternoonteas.com/wordpress to the end of the URL when a user visits it and how could /wordpress part be omitted?

Kind Regards,
Aurimas

    Rupok

    Hi Aurimas,

    So sorry to hear the inconvenience. I have never faced such issue with Domain Mapping. So I think, this is your site specific issue.

    Thanks for sending the details but I could tell you better about the issue if I could see it live, check your current configuration and make some tests on your site. Would you mind allowing Support Access so we can have a closer look at this?

    To enable support access you can follow this guide here:
    http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please confirm here when you are done granting Support Access. I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

    Nithin

    Hi Aurimas,

    Hope you are doing good today.

    I suppose you aren't using Dedicated IP, right? Could you please make sure whether you have pointed the add-on domain correctly, ie please check whether the domain to be mapped is pointed to the DocumentRoot of your WordPress Multisite, which would be for eg:
    /home/cpanel-username/public-html/

    Is this issue specific to only one subsite? Or are you noticing it when you map other domains too?

    If the Document Root is correct, could you please share the content of .htaccess file, so that we could give a closer look.

    Please do let us know how that goes, so that we could have a better idea. Have a nice day.

    Best Regards,
    Nithin

    Nithin

    Hi Aurimas,

    Hope you are doing good today.

    I suppose you aren't using Dedicated IP, right? Could you please make sure whether you have pointed the add-on domain correctly, ie please check whether the domain to be mapped is pointed to the DocumentRoot of your WordPress Multisite, which would be for eg:
    /home/cpanel-username/public-html/

    Is this issue specific to only one subsite? Or are you noticing it when you map other domains too?

    If the Document Root is correct, could you please share the content of .htaccess file, so that we could give a closer look.

    Please do let us know how that goes, so that we could have a better idea. Have a nice day.

    Best Regards,
    Nithin

    Aurimas

    Hi Nithin,

    I have tested another domain resdiary.fr which ended up redirecting to resdiary.fr/wordpress as well. This suggests that it's for all domains.

    We have a DNS A record on bestafternoonteas.com pointing at 162.13.201.40, which is a load balancer. The load balancer then forwards the traffic onto the machine that runs the WordPress instance. The IP address of the load balancer is static. There is only one WordPress install on the server, with a single root directory (/var/www/html).

    What would be the best way to share the htaccess file with you securely?

    Kind Regards,
    Aurimas

    Mahlamusa

    Hello Aurimas,

    I hope you are doing great today.

    I have accessed your website's dashboard using the staff access granted on the website and did not notice anything unusual on the settings of domain mapping but I have however noticed that in the network admin page in "Settings > Domain Mapping" there are some errors displayed on that page, the errors are as follows:

    Warning: preg_split(): No ending delimiter ',' found in /var/www/html/resdiary/plugins/domain-mapping/classes/class.domainmap.php on line 346
    
    Warning: Invalid argument supplied for foreach() in /var/www/html/resdiary/plugins/domain-mapping/classes/class.domainmap.php on line 347

    Would you please share FTP or cPanel login details so that we can see your files. We need to double check this as I have personally never encountered such errors/warning.

    In the meantime would you please enable debug logging by editing the wp-config.php file located in /var/www/html' folder. On this file, find the following line

    define('WP_DEBUG', false);

    and replace it with the line:

    define('WP_DEBUG', true);

    and below this line add the following lines

    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors', 0);

    Once you have done that, access your websites a few times and check the debug file that will be saved on the folder '/var/www/html/wp-content/debug.log'. Please share this file with us, you may upload the file to a file sharing platform like Dropbox or Google Drive and then share a link to this file using our secure contact form here https://premium.wpmudev.org/contact/. Also include the contents of the .htaccess in a text (.txt) file,

    To send the files using the contact form, please mark to my attention in the subject as follows:

    First choose "I have a different question" in the page, then enter the following details:

    Subject: "Attn: Lindeni Mahlalela"
    In the email body write the following:
    - FTP login details: host/port/username/password
    - Link to where you uploaded .htaccess file
    - Link to where you uploaded debug.log file
    - Link back to this thread
    - Any relevant additional information

    Once we have all the information we will continue troubleshooting. Please mention on this thread that you have sent the details so that we can have a look as soon as possible.

    I hope you enjoy your day further.

    Cheers,
    Mahlamusa

    Mahlamusa

    Hello Aurimas,

    I hope you are doing great today. I am sorry for the delayed response, things have been hectic on our side.

    I have received the credentials you have sent and accessed the link to Dropbox. Unfortunately I can not download the folder at once, Dropbox says 'The zip file is too large'. It seems you have uploaded your entire server into Dropbox.

    Anyway, I went through the logs, htaccess and some other files you shared and I must say it a little harder to pin point the issue at this point as I cannot make the exact same setup on my testing environment, but here is what I found and it may be related:

    In 'robots.txt', you have the following line:

    User-agent: *
    Disallow: /wordpress/wp-admin/

    It appears that you do have the folder '/wordpress' somewhere in your setup, but not sure where it is.

    In '.htaccess' file you have these lines:

    # Afternoon teas
      RedirectMatch 301 ^/wordpress\/a\/Restaurant\/Biku\/?$ https://bestafternoonteas.resdiary.com/Restaurant/Biku
      RedirectMatch 301 ^/wordpress\/a\/biku\/?$ https://bestafternoonteas.resdiary.com/Restaurant/Biku

    They also suggest the presence of a '/wordpress' directory from which you are redirecting to the other urls.

    With this I can say you should try to see the configuration files docker or composer and see where exactly is wordpress located, I believe it is the location of WordPress that has the '/wordpress' folder. But unfortunately I am not used to docker containers, so I can't give any details here.

    Please confirm if you do not have a folder like so:
    /var/www/html/wordpress
    I see wp-content is defined as
    /var/www/html/resdiary
    which suggests Docker uses some rewrites either in .htaccess or in its own config files to link the various aspects of the install. Please check if the setup does haves something like that or not.

    With regards to the warnings in the domain mapping pages, would you please disable debug by changing
    define('WP_DEBUG', true);
    to
    define('WP_DEBUG', false);

    OR tell WordPress to write debug errors and warnings to a debug.log file by adding:
    @ini_set('display_errors', 0);

    to the wp-config.php file just below the line:
    define('WP_DEBUG_DISPLAY', false);

    You may also follow the steps outlined in this thread to get rid of the PHP warnings.

    I hope this helps you pin point the issue. Please let us know if you find my suggestions useful.

    Cheers,
    Mahlamusa

    Aurimas

    If anyone else experiences this issues, the solution for this particular case was in wp_site database table "path" entry was set to "/wordpress/". Updating it to just "/" solved the issue.

    One of the way is to update your functions.php with this (make sure to remove after this code has run its course)
    // DB query to remove /wordpress/ path from Domain Mapped sites
    $wpdb->query( $wpdb->prepare(
    "
    UPDATE $wpdb->site
    SET path = %s
    WHERE ID = %d
    ",
    '/', 1, 'static'
    ) );