Download & Extend

Duplicate path aliases

Project:Subdomain
Version:6.x-2.0-beta1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Is it possible to create two nodes with the following paths

http://one.domain.com/page
http://two.domain.com/page

At the moment pathauto turns the second node alias into /page-0 which results in:

http://one.domain.com/page
http://two.domain.com/page-0

Using the Domain Access module it's possible to get this to work by prefixing the 'url_alias' table. I'm wondering if this is the only solution or if anyone has any insight into how to get this to work with the subdomain module?

The way the pathauto module works won't allow for duplicate paths. So there will have to be a reference to the subdomain the path should use somewhere, (or separate tables for each subdomain). Without hacking the pathauto module, a new module could over-ride pathauto to allow duplicate paths to be saved, then check which subdomain that path should point to... I think.

Comments

#1

I would like support on this too. Can someone give instructions on the "prefixing the 'url_alias' table" method the OP mentioned?

Thanks.

#2

For those using Drupal 7, the module Domain Path could be a solution to this. You would have to change the duplicate path manually as opposed to letting path auto do the work. Unfortunately this module will not be made available to Drupal 6.

#3

The Domain Path module actually does the reverse and also does not allow duplicate paths, so in this case is no help.

I've found a solution that works for me however:

1. Save the url aliases for nodes with their domain prefixed, so alias 'home' becomes 'subdomain/home' in the url_alias table. You can do this with some alias alter function, I create nodes programmatically anyways, so I do it by code.

2. Use hook_url_inbound_alter to lookup the correct path, like so:

<?php
function hook_url_inbound_alter(&$path, $original_path, $path_language) {
   
$_domain = domain_get_domain();
   
// Look for path alias for current subdmain
    // TODO: Take language into account
   
$result = db_query('SELECT source FROM {url_alias} WHERE alias=:alias', array(':alias' => $_domain['subdomain'] . '/' . $original_path))->fetchObject();
    if (
$result) {
       
$path = $result->source;
    }
}
?>

Hope this helps!