Reputation: 4714
What is a proper way to create a link to a subdomain of the current URL, in Drupal 7?
I.e. if I'm on http://example.com/content123, the link would point to http://subdomain.example.com/content123, thus keeping the current url, only adding a subdomain.
Upvotes: 1
Views: 1158
Reputation: 37065
The most "proper" way to handle alternate language pages is client-side, using:
<link rel="alternate" hreflang="es" href="http://es.example.com/" />
Any modern browser should handle the rest.
I'm positive Drupal will insert these for you, if you google hreflang drupal.
Here it is:
http://drupal.org/node/1200030
Upvotes: 0
Reputation: 976
Have a look at the url() function in Drupal. It allows you to create a link to a path, in a specific language.
'language': An optional language object. If the path being linked to is internal to the site, $options['language'] is used to look up the alias for the URL. If $options['language'] is omitted, the global $language_url will be used.
Upvotes: 1
Reputation: 824
There are two approaches you could take here. The first example I have shown will allow you to get to the root domain and append a new subdomain. The second example will just append a new subdomain to the current host.
Add subdomain to root domain
<?php
$new_subdomain = 'subdomain';
$split_domain = explode('.',$_SERVER['HTTP_HOST']);
echo $new_subdomain.'.'.$split_domain[count($split_domain) - 2].'.'.$split_domain[count($split_domain) - 1];
?>
Add subdomain to current host
<?php
$new_subdomain = 'subdomain';
echo $new_subdomain.'.'.$_SERVER['HTTP_HOST'];
?>
Upvotes: 2
Reputation: 6882
What you are looking for is some kind of .htaccess or similar, since using PHP for this matter isn't the way to go.
Upvotes: 0