Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting primary domain #3

Closed
davisshaver opened this issue Sep 13, 2014 · 19 comments
Closed

Setting primary domain #3

davisshaver opened this issue Sep 13, 2014 · 19 comments

Comments

@davisshaver
Copy link

Have you thought about allowing a primary domain to be set? This is a major feature of the existing solution and seems like it'd be useful to incorporate into Mercator as well.

@rmccue
Copy link
Member

rmccue commented Sep 15, 2014

As of WP 3.9+, you can set the URL to basically anything you want to change the "primary" site (you could then alias the old one back). Not sure if that fits your use case though?

(I do want to add this, but still working out the UI.)

@robrecord
Copy link

Your solutions "works", only if the primary domain is also added as an alias. No permanent redirection occurs though.

@rmccue
Copy link
Member

rmccue commented Dec 2, 2014

Strange that it needs to be added as an alias. Right now, it doesn't handle redirects simply because the code to change those hasn't been written yet. :)

I definitely want to handle this one, just haven't gotten to it yet.

@robrecord
Copy link

Yes I thought it was strange too.

I have set up a redirect at the server level for now. Thanks for contributing this work!=

@spacedmonkey
Copy link
Contributor

I am a little confused by this exchange. I am wondering if it is possible to do the following.

I have site, site.example.com. Have three aliases, www.example.com, server1.exaple.com and server2.example.com. www.example.com is the main and public domain of the site., I also want to be able hit the site at server1.example.com, without it redirecting to www.example.com. This would help as I am running a multisite over multiple servers and need wordpress to respond to whatever url I give it.

@rmccue
Copy link
Member

rmccue commented Dec 8, 2014

So, here's the question: what would you want primary domains to do?

Is the idea that other aliases would set up canonical redirects to the main domain? #28 changed the behaviour to use the alias instead, so if you have www.example.com as a mapping, but access via example.com, it'll redirect to the WWW version.

Is there a use case for having all domains redirect to the primary one? For my own use cases, I'd like to have all mapped domains redirect to the primary but with exceptions (the original subdomain, in my case). Are there any other use cases we need to handle here?

@mrjarbenne
Copy link

Is there a use case for having all domains redirect to the primary one? For my own use cases, I'd like to have all mapped domains redirect to the primary but with exceptions (the original subdomain, in my case). Are there any other use cases we need to handle here?

+1 for this. If we look at how wordpress.com handles this. For the most part aliases map over to the primary domain, except in cases where you are accessing the dashboard. In an SSL context on multisite, where the subdomain is protected by a wildcard certificate, but the mapped domains may not have individual certificates, redirecting back to the unmapped domain on login and admin calls solves the "unsafe content ahead" errors in the browser when logged in users are attempting to manage their site; but ensures the audience is always taken to the mapped domain, rather than the unmapped subdomain.

@robneu
Copy link

robneu commented Jun 15, 2015

+1 for adding the option to 301 all aliases to a single "canonical" domain.

@thatryan
Copy link

Chiming in as I think this is referencing an issue we have run into as well. Would adding this option in take care of the sites having "duplicate" content once live, meaning once a domain is mapped, or aliases, then the original subdomain the site was built on would no longer be used and redirect to the mapped domain?

@mrjarbenne
Copy link

"Duplicate content" probably isn't the right way to describe it. There is only one instance of the content (posts, pages, etc).

Think of it more like two doors to the same house. Once you are in the house, it's all the same.

One door (the mapped domain) is well lit, with a beautiful garden, and welcoming awning.

The other door (the unmapped domain) is ugly, still has the contractors name on it, and there's building material stacked around the entrance.

Right now people come in both doors and we can't control the traffic.

We need a bouncer who forces everyone to the first door: "move along, nothing to see here at this ugly back door".

@robneu
Copy link

robneu commented Jun 26, 2015

For the record, this is a duplicate content issue in SEO terms. If nothing exists to reference the single canonical resource, you will have indexation problems. Using the rel="canonical" tag does help with this, but it's not really a reliable solution 100% of the time. The ideal situation is that there is a single copy of the content and any potential "duplicates" are 301'd to that version.

A big part of why this is an issue is that links in serialized content, such as widgets or certain custom fields, will never get updated by default. To replace all instances of them you would need to use either an automated script via WP CLI or a tool like this.

When you have both duplicate copies of a site AND links to said copies, then you can wind up causing yourself some pretty serious SEO problems. This is especially true if for some reason the root domain of the network gets penalized or de-indexed for some reason. If that happens, all the sites on the network with links pointing to and originating from the root domain can be negatively affected.

@mrjarbenne
Copy link

Ahhh. That makes sense, and suddenly adds a greater sense of urgency. I hadn't looked at it that way before.

@thatryan
Copy link

Yea what Rob said. Google indexes all the subdomain "staging site" urls and sees hundreds of them in same subdomain on multisite install, all sites in same niche market as well so we are slammed lol

I have been running wp-cli search replace recursive to change all subdomain a to mapped domain once "live" but that gets cumbersome, especially iterating over several hundred sites to do it...

@thatryan
Copy link

Do we think this is something that will be addressed soon?

@scarstens
Copy link

I think I'm going to look into this today. My goal is simple here, which is to simply hook into the template_redirect action and check if you are visiting a domain that has a "mapped alias set" and redirect you (301) to the alias thats active. This will resolve 2 things:

  1. Resolve SEO issues related to dupe content of allowing the old subdomain to load.
  2. Resolve the My-Sites dropdown which currently links to the subdomains, by redirecting them to the proper dashboard url. (they will still appear to be wrong links, but I spent a long time trying to fix that, and no solutions exist that work in scale ie 300+ sites in the multisite).

@scarstens
Copy link

also noting its an issue on this endpoint, which lists "my sites" with bad links to subsites instead of aliases.
http://samplemu.dev/wp-admin/my-sites.php

@thatryan
Copy link

Any luck @scarstens ? Would love to move back to Mercator, I have a new network to setup which needs to be all https and the current mapping plugin wont do that very well.

@scarstens
Copy link

@thatryan I only partially solved the problem (just enough that we could use mercator on our local VVV installs). you are welcome to chat me on WordPress core slack and I can tell you where we are at exactly. Also none of my PR's have been handled here, so all my updates are only available at https://github.com/fansided/Mercator

@roborourke
Copy link
Contributor

@davisshaver so we opted to use WPs built in handling for setting the primary domain, that is to set the site_url to the primary domain and the subdomain as an alias.

The Mapping object now has a method make_primary() which switches the two by updating site_url, removing the alias then adding a new one with the previous site_url value.

Front end redirection issues we can handle in https://github.com/humanmade/Mercator-Redirect

humanmade/Mercator-Redirect#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants