In my site I have a custom made module that handle multiple subdomains as a single drupal site.
Here is an example of my mapping from URL to Drupal path
www.mydomain/something.htm => something
sub1.mydomain/something.htm => sub1/something
sub2.mydomain/something.htm => sub2/something
As you can see the inbound/outbound handler adds/remove the .htm from the url and also prepend the path with the subdomain if it is not "www".
Now when I try to get the path for "sub1/something" drupal show me "sub1.mydomain/something.htm" and everything works fine.
My only problem is this one:
In "sub1.mydomain/something.htm" I have a content with a link to "http://sub1.mydomain/sub2/something.htm" and this page actually exists (under the drupal path "sub1/sub2/something"
I don't know why but pathologic thinks that my "http://sub1.mydomain/sub2/something.htm" is a local url and handle that as the local path "sub2/something.htm" that is the rewritten by my outbound filter as "sub2.mydomain/something.htm.htm".
I locally patched my pathologic module by changing this line:
(isset($exploded['host']) && isset($parts['host']) && $exploded['host'] === $parts['host'])
to
(false && isset($exploded['host']) && isset($parts['host']) && $exploded['host'] === $parts['host'])
so that condition is not evaluated anymore and my absolute URL is not "rewritten" by pathologic, but I think the correct approach would be to have pathologic invoke the inbound url hooks to transform an absolute url to a local path instead of simply removing the host.
What do you think?
Comments
Comment #1
Garrett Albright CreditAttribution: Garrett Albright commentedThere are a couple of conditions under which this is expected behavior. One is that http://sub1.mydomain/ is really the URL of the root of your Drupal installation, at least at the time/context that the content is being filtered. The second is that you've added http://sub1.mydomain/ to the "Also considered local" field in Pathologic's configuration form. Are either of those the case?
At any rate, if you're a developer, you may be interested in using hook_pathologic_alter() to alter Pathologic's output or stop it from modifying certain paths entirely. See the pathologic.api.php file in the module directory for all the details.
Comment #2
bago CreditAttribution: bago commentedThank you for the hint about using pathologic API instead of patching pathlogic, I will try for sure!
I'm still wondering if pathologic should generically pass absolute urls he thinks are local to some method that will convert it to a real local path (passing the inbound url hooks too) instead of just striping away the hostname. I know inbound/outbound alter hooks are not so "commonly used" but I fear that pathologic can easily do the wrong thing when used with such modules.
I'm thinking to "drupal_get_normal_path($path, $path_language = NULL)" that internally calls the inbound_url_alter hooks. But, I just see the methods take a path and not an URL, so this wouldn't solve my issue. Maybe my issue is strictly related to the way I "abuse" of multiple subdomains for a single website sections: feel free to close this issue as invalid, if this is the case.
Comment #3
Garrett Albright CreditAttribution: Garrett Albright commentedbago, any update? Is hook_pathologic_alter() suiting your needs for now?