I am not sure if I am doing this right. I just bought the virtualmin pro to try out. I am deciding between this and cpanel. So far I like what I see. However I have one feature that I can not make work, doesn't work how I expect it to or something.

Lets see if I can explain this correctly.

I have domain example.com. I add it as a virtual server and it consumes one of the licenses. All works great.

Now, I want to add a sub domain to this. Ok, so I have read that you have sub servers and the such.

But based on what I want I add a subserver with the domain, abc.example.com but it makes it own name space and consumes another license. I have used subdomains a lot in cpanel and so I use them alot.

so this is what I want to do.

abc.example.com ---> example.com/abc now I can do RewriteCond %{HTTP_HOST} =acb.example.com RewriteRule ^(.*) http://example.com/abc/ [R]

however when I go to abc.example.com to basically redirects to example.com/abc in the address bar/

I want to have it abc.example.com in the address bar always but also able to access it from example.com/abc

Does this make since?

Status: 
Closed (fixed)

Comments

One thing that you could do is is configure Virtualmin to accept requests for all sub-domains under example.com - this can be done at Server Configuration -> Website Options -> Website matches all sub-domains?. You can then add the RewriteRule above to serve any sub-domain from the sub-directory of the same name.

Would that work for you?

That works, but again it changed the address bar.

So http://abc.example.com changes to http://example.com/abc

Not really what I want and when trying to put order on a big website doesn't look as good.

what I am wanting the address bar to do is this,

movies.example.com/actors/80s

or

music.example.com/artists/70s

looks better and is how my current website is set up over

example.com/movies/actors/80s example.com/music/artists/70s

a live example is go to http://test.kudusystems.com this is the same as http://kudusystems.com/test however you notice the address bar doesn't change and you can access it from both.

Now do your example, http://photostor.kudu4u.com it changes the address bar.

Its just a look and I am sure I am being picky, just a limitation of virtualmin I guess. I am assuming with unlimited domains, I can make a sub servers that will do the same thing?

This is sort-of out of the scope of Virtualmin, but I am pretty sure what you want can be done using Apache's mod_rewrite directives, like RewriteRule. You can set this in httpd.conf manually via the UI (at Services -> Configure Website) ... and Virtualmin won't complain about these types of changes.

Full docs are at : http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

Thanks,

I had wondered. I will do the research. I think I am gonna keep virtualmin for now anyways. Cpanel is just too much per year.

Joe's picture
Submitted by Joe on Tue, 12/14/2010 - 13:46 Pro Licensee

Note that this is intentional in Virtualmin. The whole "subdomain" concept in cPanel is, frankly, idiotic and confusing to users that aren't familiar with it.

There was a subdomain account type in Virtualmin for a couple of years, that acted like the cPanel subdomain...but it confused a lot more people than it helped, and people thought they needed to use a subdomain account to have a subdomain named server (when a sub-server or a regular virtual server can have any name you want), and so they kept wanting to do advanced stuff with subdomains which are impossible with the limitations of how subdomains work (being just a subdirectory of the parent public_html, those kind of accounts can't have mailboxes, can't have separate logins, can't have independent databases and users, etc. because it's just a subdirectory and an httpd rewrite rule).

In short, we've never seen a good reason to use subdomains (note that subdomains consumed licensed domains in Virtualmin just like subservers). Only aliases do not consume licensed domains. Any time you have a separate website Virtualmin counts it as a domain. And, it sounds like your primary purpose for using subdomains was to avoid consuming licenses for new websites...which wouldn't work, even if subdomains still existed in Virtualmin. (You never see this issue in cPanel because it is only available in an unlimited domains license, which, as you note, costs a lot more than a small domain license from Virtualmin.) ;-)

While Jamie has provided lots of details on how to achieve what you're after, I kinda wonder if maybe there aren't better ways to solve the problem than cramming more websites into the public_html of your top-level domain. But, if cost is a significant factor and upgrading to a larger Virtualmin license is not an option, then I guess it is one way to get around the license limit. When we removed the feature, there was some discussion in the forums about replicating it mostly automatically via Server Templates. If you wanted to get really fancy, I suspect you could even use Custom Fields to add a section to the Create Virtual Server and Edit Virtual Server pages to allow users to add or remove subdomains. But, again, that's really bending things in nasty ways that don't really makes sense...I've never been able to figure out why cPanel even has such an account type. It really just doesn't make any sense.

Oh, I am sorry I didn't mean it to sound like I was trying to get out of buying more licenses. grins, I am going to upgrade to the unlimited very shortly. :) I am so sorry if I made it sound like I was trying get out of something. It really wasn't the case.

I am just very use to cPanel and was looking for similar functionality as all my websites are written to use sub domains heavily and I don't want to re write them. kudu = lazy lol

Jamie did point me out to what I needed to read.

I use sub domains to organize and quick reference my web sites. Once you get the idea in your head, its really really useful. A good example is msn.com. They use it to get quick access to the different parts of the same site. Like movies.msn.com I do the same.

But again Jamie pointed me to where I needed to go and I learned.

the reWrite does do what I wanted but I need a bit more code to it to make it work.

RewriteCond %{HTTP_HOST} ^photostor.kudu4u.com$

RewriteCond %{REQUEST_URI} !^/photostor/

RewriteRule (.*) /photostor/$1

This gives me close to the desired effect, if not. I was making the rewrite rule wrong. I have to work on it a little more to be sure but i think it will do it happily.

I am sorry to have wasted as much time of yours as I did. However, it did cause me to really learn virtualmin, and I like it.

Now I can start converting my servers over and getting my clients to switch over.

Thanks a bunch and I am sorry to have made it sound like I was trying get out of licenses and such.

Kudu

~edit

I worked a little more and got this.

RewriteCond %{HTTP_HOST} !^(www.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} !^(admin.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} !^(webmail.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).kudu4u.com

RewriteCond %{REQUEST_URI} !^/%2/

RewriteRule (.*) /%2/$1 [L]

This should work on any folder and sub domain you want. You can add exclusions based on the first line.

Now, I assume I could edit this into the template so every server made can have it.

Thanks again!!!!!!

Joe's picture
Submitted by Joe on Tue, 12/14/2010 - 14:30 Pro Licensee

No one's accusing anyone of anything here. ;-)

We don't mind if folks make use of rewrite rules and stuff to accomplish this kind of thing, even if it is to avoid spending money (though the free Virtualmin GPL may be a better choice if cost is the biggest factor in decision making). We happily spent quite a bit of time in the forums working with the few folks that were in your situation and wanted to keep doing things the cPanel way while they migrated to full sub-servers (which should also do what you want, though you'd need to update your paths if they rely on things being in subdirectories).

The problem with subdomain accounts was one of extreme confusion for users, so it really just had to go. The amount of support time we spent trying to convince people that subdomains were a special case and were extremely limited, and were not required for having a domain that happens to have a subdomain name (as I mentioned, we had tons of users thinking that was the only way to have a domain named sub.domain.tld, when in fact you'd usually want a Virtual Server or a Sub-Server for that purpose; only when coming over from cPanel does it really make sense to use a subdomain). These days, subdomain accounts are converted to Sub-servers, with most features disabled, when they are migrated from cPanel.

In short, you can probably do everything you want with Sub-Servers, though it does alter the path. But it does allow you to share databases, file access, etc., and have a single point of administration for all of the domains, while also allowing dramatically more capabilities for each domain (though all of those capabilities are optional; you don't have to permit mailboxes to exist, or have extra databases, or whatever; it can just be another website just like the subdomain in cPanel). The only difference in such a case is that the path of public_html is:

/home/domain/domains/sub.domain.tld/public_html

Rather than:

/home/domain/public_html/sub/

A bit more typing for a lot more flexibility.

Smiles, Cool.

I edited my post above but I will put it here just in case.

the rewrite rule I came up with.

RewriteCond %{HTTP_HOST} !^(www.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} !^(admin.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} !^(webmail.)?kudu4u.com [NC]

RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).kudu4u.com

RewriteCond %{REQUEST_URI} !^/%2/

RewriteRule (.*) /%2/$1 [L]

is also a good work around for somebody who wants what I wanted. It just allows for any folder in the public_html to be come a sub domain. Very handy, and actually easier to use then what I am use to.

Again thank you for your help and time. I will be telling other people I know who use other control panels how nice vituralmin is and how friendly the support and forums are.

Kudu

Cool, glad you got that working! RewriteRule is incredibly complex, and I still struggle to get it to do what I want :-)

Automatically closed -- issue fixed for 2 weeks with no activity.