# Site subdomain paths?

**URL:** <https://forums.interworx.com/t/site-subdomain-paths/12826>\
**Category:** Hacks / Tools / Tips / Tricks\
**Tags:** subdomain, directories, path\
**Created:** [November 12, 2010, 2:06pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826 "2010-11-12T14:06:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghost1227](https://forums.interworx.com/user_avatar/forums.interworx.com/ghost1227/32/58_2.png) [@ghost1227](https://forums.interworx.com/u/ghost1227)\
**Post date:** [November 12, 2010, 2:06pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/1 "2010-11-12T14:06:35Z")

</div>

The default way that InterWorx handles site paths for subdomains is:

```auto
/home/<user>/<domain>/html/<subdomain>

```

This is fine, but for sites that have many subdomains it makes it difficult to identify files/directories that are part of the master domain. Is there any way to make it create the directories like one of the two following examples?

```auto
/home/<user>/<domain>/<subdomain>

```

```auto
/home/<user>/<subdomain>

```

This is the only complaint I have with InterWorx, I’d love to see a resolution.

---

<div class="post-metadata">

**Author:** ![EverythingWeb](https://forums.interworx.com/letter_avatar_proxy/v4/letter/e/8baadc/32.png) [@EverythingWeb](https://forums.interworx.com/u/EverythingWeb)\
**Post date:** [November 13, 2010, 11:17am UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/2 "2010-11-13T11:17:00Z")

</div>

Could you not add them as ‘secondary domains’ on the same account?

---

<div class="post-metadata">

**Author:** ![ghost1227](https://forums.interworx.com/user_avatar/forums.interworx.com/ghost1227/32/58_2.png) [@ghost1227](https://forums.interworx.com/u/ghost1227)\
**Post date:** [November 14, 2010, 7:47pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/3 "2010-11-14T19:47:38Z")

</div>

Re

You could, but that overcomplicates it more than should be necessary.

---

<div class="post-metadata">

**Author:** ![IWorx-Dan](https://forums.interworx.com/letter_avatar_proxy/v4/letter/i/d2c977/32.png) [@IWorx-Dan](https://forums.interworx.com/u/IWorx-Dan)\
**Post date:** [November 15, 2010, 2:14pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/4 "2010-11-15T14:14:40Z")

</div>

Ghost,

Unfortunately EverythingWeb has the only real solution - to create a secondary domain instead of a subdomain. Every “sub domain” will then have it’s own html/ directory that is separate from the master domain. It would be difficult to change the behavior of InterWorx subdomains to the way you describe.

---

<div class="post-metadata">

**Author:** ![ghost1227](https://forums.interworx.com/user_avatar/forums.interworx.com/ghost1227/32/58_2.png) [@ghost1227](https://forums.interworx.com/u/ghost1227)\
**Post date:** [November 15, 2010, 2:16pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/5 "2010-11-15T14:16:41Z")

</div>

Re

Let’s say that I’m efficient with most web languages… Would it be possible for me to modify the code in such a way or would trying just be a waste of time?

---

<div class="post-metadata">

**Author:** ![IWorx-Dan](https://forums.interworx.com/letter_avatar_proxy/v4/letter/i/d2c977/32.png) [@IWorx-Dan](https://forums.interworx.com/u/IWorx-Dan)\
**Post date:** [November 15, 2010, 6:49pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/6 "2010-11-15T18:49:09Z")

</div>

Well since you seem adamant, I’ll give you a solution but it’s kinda hacky and it won’t work 100%. The secondary domain is a much cleaner solution as it can be controlled from the control panel and you aren’t “tricking” Interworx into behaving differently.

As I understand it, you want to segregate subdomain and master domain directories so they don’t get confusing, which is fine. The solution I have is to make a dedicated sub-domain root directory and move all your subdomain dirs into the root. Then, modify the httpd vhost config file to have the rewrite rules point to a different directory. Keep in mind, adding new subdomains will require you to manually move the subdomain directory to the subdomain root, and I’m not really sure what will happen when you try to delete a subdomain that has it’s directory in the subdomain root. Procedure:

[LIST=1]

- ``` cd /home/user/domain/html ```
- Create a new directory to act as the subdomain root inside your html directory. you can call it whatever you want. I chose "subdomains". ``` mkdir /home/user/domain/html/subdomains ```
- Move all subdomain directories into the new subdomain root you have created. ``` mv sub1 sub2 sub3 .. subdomains ```
- ``` cd /etc/httpd/conf.d ```
- Find the vhost file for the master domain. It will look like vhost\_[master domain].conf. First, make a backup in case something goes wrong. ``` cp vhost_domain.conf /root/ ```
- Use whatever text editor you prefer and open the file, I use vim. ``` vim vhost_domain.conf ```
- Inside the #subdomain logic section, edit the following lines: Change these lines (there should be 2): ``` RewriteCond %{DOCUMENT_ROOT}/%1 -d ``` To look like this (replace subdomains with whatever root name you chose): ``` RewriteCond %{DOCUMENT_ROOT}/[B]subdomains/[/B]%1 -d ```
- Change ``` RewriteRule ^([0-9A-Za-z-.]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L] ``` to read: ``` RewriteRule ^([0-9A-Za-z-.]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/[B]subdomains/[/B]$1/$2 [L] ```
- Change ``` RewriteRule ^www\.([0-9A-Za-z-.]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L] ``` to ``` RewriteRule ^www\.([0-9A-Za-z-.]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/[B]subdomains/[/B]$1/$2 [L] ```
- Save and quit. (:wq in vim)
- Restart httpd to reload the config files ``` service httpd restart ```
- In any case, if you’d rather not go through this procedure, I have notified the developers about this. We also have some people requesting that the way sub domains work is changed because litespeed httpd doesn’t like the way we do it. There is a good chance in the future we will make it so you can specify which document root you want for a subdomain.

---

<div class="post-metadata">

**Author:** ![ghost1227](https://forums.interworx.com/user_avatar/forums.interworx.com/ghost1227/32/58_2.png) [@ghost1227](https://forums.interworx.com/u/ghost1227)\
**Post date:** [November 15, 2010, 6:52pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/7 "2010-11-15T18:52:06Z")

</div>

Wow…

Didn’t expect that much assistance 🙂 Thanks for the reference, I’ll take a look at it, and the system itself and see if that can be made to work the way I want it to. Definitely looking forward to system updates too.

---

<div class="post-metadata">

**Author:** ![R-n-R](https://forums.interworx.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@R-n-R](https://forums.interworx.com/u/R-n-R)\
**Post date:** [November 16, 2010, 11:55am UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/8 "2010-11-16T11:55:47Z")

</div>

Just want to add the following, is how subdomains will effect your clients or your sites SEO and SERP. The reason I say this, I love the way InterWorx handles Secondary Domains, verses how cPanel places Addon (cPanel’s version of Secondary) domains in the web root directory…that’s a SEO CATASTROPHE. We found out the hard way when had SERP bleed over to a Addon site that shouldn’t have been there in the SERP which makes that subdomain HIGH risk of duplicate content!! The fix is via the .htaccess file, but it shouldn’t be that way.

Now regarding Subdomains on InterWorx, Search Engines look at Subdomains as totally separate sites, since I do not use Subdomains that much and when I do I just set up its own SiteWorx Control Panel to make it clean, I am not sure if using /\<user\>/\<domain\>/html/\<subdomain\> would give the same SERP bleed (and risking Duplicate Content) like cPanel does with Addon domains. But the risk is there unless you use the Robot.txt to disallow that directory, but that could cause other problems of the subdomain being indexed at all. But the clean way would most differently to keep it outside of the web root documents area all together.

Food for thought.

---

<div class="post-metadata">

**Author:** ![interlock](https://forums.interworx.com/letter_avatar_proxy/v4/letter/i/f17d59/32.png) [@interlock](https://forums.interworx.com/u/interlock)\
**Post date:** [December 13, 2010, 12:02pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/9 "2010-12-13T12:02:49Z")

</div>

> [@EverythingWeb;17754](#):
>
> Could you not add them as ‘secondary domains’ on the same account?

This is actually the best solution regardless. Subdomains uses url rewriting, which breaks in nearly every case if the sub domain attempts to use it. We’ve disabled subdomains as a policy within our company purely for this reason. Ideally, interworx would update how they make the apache templates to do subdomains as an actual vhost instead of using a massive rewrite rule system, but that’s a talk for another day…

---

<div class="post-metadata">

**Author:** ![IWorx-Dan](https://forums.interworx.com/letter_avatar_proxy/v4/letter/i/d2c977/32.png) [@IWorx-Dan](https://forums.interworx.com/u/IWorx-Dan)\
**Post date:** [December 23, 2010, 1:14pm UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/10 "2010-12-23T13:14:25Z")

</div>

> [@interlock;17834](#):
>
> This is actually the best solution regardless. Subdomains uses url rewriting, which breaks in nearly every case if the sub domain attempts to use it. We’ve disabled subdomains as a policy within our company purely for this reason. Ideally, interworx would update how they make the apache templates to do subdomains as an actual vhost instead of using a massive rewrite rule system, but that’s a talk for another day…

This is actually something that has been requested for multiple reasons. Changing the way subdomains work is on our ‘todo’ list.

---

<div class="post-metadata">

**Author:** ![banning](https://forums.interworx.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@banning](https://forums.interworx.com/u/banning)\
**Post date:** [January 23, 2014, 11:04am UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/11 "2014-01-23T11:04:50Z")

</div>

> [@IWorx-Dan;17850](#):
>
> This is actually something that has been requested for multiple reasons. Changing the way subdomains work is on our ‘todo’ list.

So I see this got put on your todo list in 2010… did it ever get todid?

---

<div class="post-metadata">

**Author:** ![d2d4j](https://forums.interworx.com/user_avatar/forums.interworx.com/d2d4j/32/16_2.png) [@d2d4j](https://forums.interworx.com/u/d2d4j)\
**Post date:** [January 26, 2014, 3:54am UTC](https://forums.interworx.com/t/site-subdomain-paths/12826/12 "2014-01-26T03:54:34Z")

</div>

Hi Banning@posim.c

I believe this has been completed as described above.

If you would like to check for yourself, if you goto a one of your siteworx accounts, or create a test siteworx account on your system, Administration, subdomain, and create a new subdomain, you should see the path, which is automaticaly created when the subdomain is added, so it will look similar to /domain/html/subdomain.

Many thanks

John
