Site subdomain paths?

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


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?


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

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


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


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.


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?

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:


  • ``` 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 ```
  • Test! If stuff goes wrong, move all your subdomains back out of the root, copy your backup vhost config file back, and restart your webserver again. [/LIST]

    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.

  • Wow…

    Didn’t expect that much assistance :slight_smile: 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.

    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.

    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.

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

    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