Subdomain redirect dashboard

I am trying to work out one last issue I am having with my WPMS setup. The primary website is: domain.tld. The users can register for a subdomain’s. When the user logs into the dashboard it redirects them to their subdomain/wp-admin/.

I do not want this, I would rather them stay at domain.tld/wp-admin/.

This is important for me because user generated content needs to be collected on one server and uploaded to a object store. The other servers in the farm are simply slaves and do not store any user generated content. I have been messing around with the following code (as well as various plugins).

`// Redirect to https login if forced to use SSL

if ( force_ssl_admin() && !is_ssl() ) {

if ( 0 === strpos($_SERVER, ‘http’:wink: ) {

wp_redirect(preg_replace(‘|^http://|’, ‘https://’, $_SERVER));

exit();

} else {

wp_redirect(‘https://’ . $_SERVER . $_SERVER);

exit();

}

}

Anyone have a suggestion to keep all users regardless of the subdomain logged into a single dashboard URL?

  • Philip John
    • DEV MAN’s Apprentice

    Hiya,

    Honestly I’m not sure this is possible.

    The only way I can see it working at the moment is if you added a rule like this into your .htacess:

    RewriteCond %{HTTP_HOST} ^!(domain.tld) [NC]
    RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]

    Be warned that I haven’t tested that and it may be completely wrong. Plus, it’ll need modifying so that it only redirects the backend not the frontend too.

    Phil

  • Mason
    • DEV MAN’s Sidekick

    Yeah, as you’re wanting to limit things to one server that’s pretty well outside our ability to support here on these forums. You could ask for some custom development in the Job Boards – or look for a good server admin to provide you with a solution.

    Thanks!