I apologize if this is a duplicate. I've been searching through the issue queue and my head is spinning but I haven't quite figured this out.
I have legacy nodes from before DA that I am filing into the proper subdomain. Each of these are assigned to the subdomain as well as the main domain (the main domain acts as a hub for all content from all subdomains). Because they are assigned to the main domain, you can go to these nodes on the main domain with no error. This isn't what I want, though. I want them to be listable on the main domain but actually go to the subdomain when clicked.
I turned on the rewrite option so all lists point you to the domain and that's great. But the search engines and other links are already pointing to the main domain for these nodes. I can't use path redirect because the path I'm redirecting from is a valid path and it errors. I saw the domain redirect module in one of these issues but that seems to be for redirecting from content that isn't available on the current domain, which isn't the case.
Since there's only about 200 legacy nodes and future nodes should be ok with the rewrite rule, I wonder if I should put something in .htaccess? Is there a better way that I'm missing?
Thanks,
Michelle
Comment | File | Size | Author |
---|---|---|---|
#15 | domain-714986-D6.patch | 1.17 KB | mikeytown2 |
Comments
Comment #1
agentrickardDomain redirect is the closest thing to what you describe. DA only handles the links that Drupal writes, it doesn't control inbound requests.
Comment #2
MichelleYeah, and domain redirect doesn't do what I want. If there's nothing in DA for this, I'll investigate adding the links manually to .htaccess.
Thanks,
Michelle
Comment #3
agentrickardIt would be pretty trivial to write a small module that handles this. You might need a redirect flag on the node, though.
Otherwise, a little code in hook_init() might do it. You could also do this in hook_nodeapi('view').
The second code is probably cleaner, since it doesn't depend on module weight for execution order. You'd also want to check that $domain is active and accessible to the user.
Comment #4
agentrickardYou know, if that second piece of code works, I would consider making it a configurable option in the module.
Comment #5
MichelleWow, thanks! I'll give it a whirl this evening when the kids are in bed and let you know. Would be great having it right in the module. I'm sure I'm not the only one to ever have legacy nodes, though my having them on both the subdomain and main domain might be a little edge case-y.
Michelle
Comment #6
agentrickardIt has come up more than once before, and I have rejected it. But recent changes (and the
domain_get_node_match()
function make this really simple to do, I think.But that assumes Drupal makes it to nodeapi $op 'view'. It might not.
Comment #7
MichelleI got caught up with other stuff tonight and just realized I forgot to try this now as I'm headed to bed. Tomorrow night is spoken for, I'm afraid, but will try it out first thing Wednesday evening. I appreciate you helping out and sorry I forgot to test it out.
Michelle
Comment #8
agentrickardTagging.
Comment #9
nonsieWhat about use cases where such redirect is not desired e.g. if a node is published to the default domain and a subdomain and the user is viewing it on the default domain and should not be redirected? In a way this is similar to how we handle SEO rewrite at the moment - either show on all domains or redirect to the best match.
If this is going in it needs to be configurable per install.
Just my 2 cents.
Comment #10
agentrickardYes, config per install was my thought, too. Config per node would be even better, but not quick.
Comment #11
agentrickardComment #12
hefox CreditAttribution: hefox commented(Been using the hook_init without any troubles on my own site for a while, needed it for another site so stuffed it into a module. Didn't try the nodeapi, as I use panels. Tell me if ya prefer I don't have it up on github. http://github.com/hefox/domain_redirect.)
Comment #13
agentrickardThere's easier code for this:
Comment #14
mikeytown2 CreditAttribution: mikeytown2 commentedsubscribe/tracking
Comment #15
mikeytown2 CreditAttribution: mikeytown2 commentedHere's a patch for 6.x. Gives user link to story on source domain in a message box. This patch makes the assumption that you do not want to go to domain_id = 0 via #867934: Do not redirect to domain_id=0
Sidenode: I think calling something like domain_access_denied() which would then allow for some default behavior and hooking when access_denied is called could be useful.
Comment #16
agentrickardNew features go to 7.x.
Comment #17
agentrickard7.x.3 to be exact.
Comment #18
agentrickardComment #19
MichelleI forgot about this issue. Just as an FYI, I am no longer using DA. Nothing against the module; just turned out to be too confusing for my users and I'm scaling down the site, anyway. I think it's still a decent FR, but don't do it just for me. :)
Michelle
Comment #20
rogical CreditAttribution: rogical commented+1 www.example.com/article/news1 --> news.example.com/artile/news1 this is very much need!
Comment #21
camdarley CreditAttribution: camdarley commentedI think that:
could be replaced by
It works for me and allow to publish content on multiple domains.
Comment #22
jan.s CreditAttribution: jan.s commentedHi camdarley,
keep in mind you must provide a new domain to domain_goto().
See my solution at this issue: http://drupal.org/node/1566058
Comment #23
rogical CreditAttribution: rogical commentedI think this feature is very common, big sites like Yahoo!, promte/sticky contents from subdomain show on main domain site, and redirect on visit.
#1646586: Auto create domain url based on Source domain is also a good substitute.