# How can I create a menu item on a different subdomain?

I want to create a menu-structure like this in Joomla 2.5:

• Root (www.example.com)
• About (www.example.com/about)
• Site a (a.example.com)
• Site b (b.example.com)

Is it possible to create menu items with different subdomains and how do I create them? I worked with the CMS "typo3" previously and there was no problem in doing this, but a long search through the internet didn't help me with this problem.

EDIT: Note that a.example.com and b.example.com are on the same Joomla installation, so I'd like to make a new "Single Article" with a subdomain.

• Please give us more information on your Joomla setup. How are you serving the subdomains from one Joomla installation? – TryHarder Apr 30 '14 at 16:29
• What is the content for site a and site b? Are these just single menu items that link to an article or are they more robust with their own menu and pages? – David Fritsch Apr 30 '14 at 23:01
• I'm sorry I didn't had time for answering yesterday. I'll serve those subdomains to the same Joomla installation and than joomla or a component has to do the redirecting(a.example.com and not www.example.com/a.hmtl) – Marc T. May 2 '14 at 6:24

I haven't try it, but Artio JoomSef claims to provide such functionality.
You can specify sections of your website to be used for different subdomains. It might be worthy to check it.

Artio JoomSEF documentation

If you are looking for more complex configurations, Joomla MultiSites extensions allows you to run many joomla sites, from one installation, with various configurations. A link to this JED section is provided in another answer here.

• This is at a short look pretty much that what I wanted. I know the component Multi Sites too, but I don't want multiple websites. – Marc T. May 2 '14 at 6:18

menu-item parameters > menu item type > system links > choose "External URL"


Then in the Link field you can type the URL of your sub domains.

• Sorry, i wasn't clear enough. I made an edit above. It should be the same joomla installation AND the same site. – Marc T. Apr 30 '14 at 15:13

You can't really do this with native Joomla, but you can use a extension that try to help you doing this.

You can find them at JED

If you don't want to use an external component for this, then you can create an external URL in your menu pointing to a.example.com and use your .htaccess file to get content from your site's existing link.

For example

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^a.example.com
RewriteRule ^(.*) http://example.com/$1 [P] </IfModule>  Suppose, if your user visits this URL a.example.com/user/sd, then the content will be of example.com/user/sd without changing actual URL on browser. Go with this method only if you are well familiar with .htaccess file usage and ok with manual editing. This is useful if you don't want to use entire new extension for just few urls. I know this is a bit old this question but I was wondering the same thing and here is the solution I came up with if you change the templates index.php file with a bit of extra code you could create multiple module positions based on the subdomain, and then you assign the correct menu item to the relevant subdomain. $dom = explode ( '.', str_replace ( '//', '.', JURI::base () ) ) ;
$sub = ( in_array ( 'plus',$dom ) ? 'plus' : ( in_array ('group', $dom) ? 'group' : 'home' ) ) ; if ($this->countModules('navigation'.$sub )) : ?> <nav class="navigation"> <jdoc:include type="modules" name="navigation<?php echo$sub ?>" style="html5" />
</nav>
<?php  endif; ?>


In the above example the line starting $sub is what you'd need to customise for your own website, at present the example creates a space for a navigation module depending on the subdomain - this was created for a site with two sub domains and a general domain and so it creates three navigation positions for each subdomain - navigationhome navigationplus and navigationgroup. A few things to note with the code - to find the subdomain I've used the function in_array. I could have used a switch statement on$dom[1] to find the subdomain but this wouldn't work if someone typed something like www.plus.mysite.co.uk as www would be in $dom[1]... e.g.  switch ($dom[1] )
{
case 'group' : $sub = 'group' ; break ; case 'plus' :$sub = 'plus' ; break ;
default : $sub = 'home' ; break ; }  the initial explode uses str_replace to replace // with . this is so that the initial http / https ends up in it's own array ($dom[0] will always contain the http/https which I suppose could be used further if you wanted to show different sites depending on the protocol loaded, if that wasn't there then is someone put in something like http://plus.mysite.co.uk then the first array would contain http://plus and in_array would return no match.

Bear in mind that if the sub-domain is the same as the site domain then you'd need to make sure it's the last one in the ? : statement chain otherwise it will assign itself to other subdomains - e.g. if you had two sub domains one called site.site.co.uk and the other site1.site.co.uk the following statement would work

    $sub = ( in_array ( 'site1' ) ? 'site1' : ( in_array ( 'site' ) ? 'site' : 'site' ) ) ; //it never reaches the in_array ( 'site' ) if sub domain is site1  but neither of these would work properly in that situation... $sub = ( in_array ( 'site' ) ? 'site' : ( in_array ( 'site1' ) ? 'site1' : 'main' ) ) ;
// all domains would be referred to as site because XXX.site.co.uk provides a match
\$sub = ( in_array ( 'site1' ) ? 'site1' : ( in_array ( 'site' ) ? 'site' : 'main' ) ) ;
// www.site.co.uk would still be site and not main


It's unlikely you'd be using these in this manner but it's worth noting.

Yes, you can create that menu structure in Joomla. In general the menu items point to a view in a component specifying the item and other parameters.

When you install Joomla with the learning demo data, you'll notice two completely different sample sites, including the learning demo, teaching you everything about Joomla.

• Can you expound on this? I've never seen a subdomain used like this with a stock joomla setup. It always required a SEF plugin to override the stock stuff. Two different looking sites yes, but not from the menu with subdomains as their urls. – Brian Peat May 1 '14 at 17:00
• The content of a joomla site is not related to (sub)domains. You configure your network and webserver to deal with that. – sovainfo May 1 '14 at 17:11
• Right, but your answer doesn't actually give a solution. I suspect the solution includes setting up dns correctly and then using the external menu link to send the user to the subdomain name. Otherwise, you'd just end up at a regular page in joomla (if you simply link to an article). It's not a straight forward setup at all. – Brian Peat May 2 '14 at 0:10
• Don't have clear instructions. Recall setting up two shops using hikashop this way, years ago. Don't recall the details. You probably want some things in .htaccess to direct to appropriate urls. Very much depending on your requirements. – sovainfo May 2 '14 at 10:17
• I would suggest removing this answer then. It's really not giving the OP a whole lot of info. – Brian Peat May 2 '14 at 12:31