Your comments

That last method worked. Thank you very much!!
I just wonder why adding a *.domain.com in the same website and a conditional rewrite in the Custom Configuration doesn't work...
Thanks for your response Janxb. Actually what I want to achieve is something different. I will explain using real domains so it will be clearer.

For instance, I have http://romanrandom.com/. If instead I access http://www.romanrandom.com/, it will automatically rewrite the domain removing the www, which is what I want. But if I access http://something.romanrandom.com/ no redirection happens, which is not good, although the page displays. And this is a wordpress site; with other types of site the www subdomain doesn't work either.

And there is another issue. Take http://aguo.audio. If you add any subdomain, http://something.aguo.audio it will happily take you to the site at http://romanrandom.com/ leaving the url unchanged, and that's really bad...


So basically what I want is that all subdomains of my domains are removed from the url, apart from a few that go to different sites. I had this set up with Apache and Lighttpd, but after discovering Ajenti I started fancying the idea of not having to use the command line for everything and installed it with Nginx, which I have no experience with. I could learn how to setup Nginx through it's configuration files, but that would defeat the purpose of my migration to Ajenti. And for SEO purposes I would really like to be able to set the subdomain redirections correctly.

Thanks again for your time!










I tried this solution but it doesn't work for me. Also tried this to no avail:
server {
server_name *.mydomain.com;
rewrite ^(.*) http://mydomain.com$1 permanent;
}
Please, give me some hint!