If a user visits a page that Domain Access blocks for them, they get a permissions issue. I would like instead to attempt to redirect them to a subdomain in which they DO have access to that node.
This desire springs from the links that are included in the alert emails for OG. Right now they point to the root domain, and a lot of members don't have sufficient rights to view them there, only on the subdomains the posts were published to. I thought about fixing it in OG directly, but I'm hoping this approach would cut off other potential problems down the line.
My suspicion is that creating a custom 403 page with a little php code that searches all the available domains and eventually does a domain_goto would do the trick. I'm already working on this, but I thought someone else might have already done it and be willing to share. If I figure it out I'll post it back here.
Comments
Comment #1
gcassie commentedIt would also help solve the problem of URLs in RSS feeds being directed only at the root site.
Comment #2
agentrickardUsing Domain Source or turning on SEO should solve this problem by forcing all links to write to the proper domain, but you would need to upgrade to 5.x.1.4 as well.
You can also "fix" the feed issue by putting the following into 'Special page requests'
Doing so will cause DA to ignore its access rules when that path loads and write the URLs to the proper destination domain.
Comment #3
gcassie commentedFirst test seem to show that upgrading to 5.x-1.4 fixed the links in the feeds and OG emails, which was great. Thank you for that suggestion.
I should mention that upgrading from 5.x.-1.1 to 5.x-1.4 replaced all the entries in the domain_access table with default values. I was able to restore them from a backup.
Comment #4
gcassie commentedI still had people hitting pages from the wrong domain for whatever reason. I've added a bit of code to my custom 403 page. If the user is trying to just view a node that is only published to a single domain and they just happen to be on the wrong domain, this will bounce them to a domain where they can view it.
Comment #5
agentrickardI think that #255711: Redirect search engines may be related to this. So one of these is a duplicate.
Comment #6
gcassie commentedFrom what I can see there, that module deals with spiders. Which is very useful, but most of my wrong domain issues come from writers and editors not linking to the proper domain within content they've created. I think 255711 would bypass that because the user agent is not a spider.
Comment #7
agentrickardI think 5.x.1.6 solves this issue. If a server request for a non-existent domain is received, we pop the user to the primary domain and post a message.
See #293453: Wildcard DNS - default domain
Comment #8
Ibn al-Hazardous commentedThe module in "redirect search engines" (255711) has on option in the domain advanced settings, so you can redirect all visitors.
I suppose the problem with using it for ordinary users is that the user doesn't get a heads up - but is quietly sent a redirect http header. So if you want to give the user a "change your bookmarks" message - maybe some php and javascript (to get a timed out redirect) in your 403 is a better solution? Depends on what you want to do.
Comment #9
agentrickardLike #255711: Redirect search engines, I do not intedn to commit this.
Comment #10
freestyler commentedI also have custom error + domain access
I tried gcasie's code and at first it didnt worked (im on drupal 6)
To make it work I had to change the === for >= in the following line:
now I get a redirect error (an infinite loop) caused by drupal_goto, on this line:
Arguments are ok as I printed them on screen and I even managed to redirect via javascript.
Can anyone help me solve the drupal_goto infinite redirect?
Comment #11
agentrickard