0
Redirect subdomains to corresponding main domain
Hi!
I have multiple websites set up with multiple domains and I'm trying to redirect every subdomain to it's main domain, like this:
*.domain.com => domain.com
The problem is that no matter what I do all the subdomains apart from www get redirected to one domain:
w.domain1.com => w.domain1.com
w.domain2.com => w.domain1.com
w.domain3.com => w.domain1.com
...
Only www stays at the correct domain, but doesn't redirect... except for Wordpress websites:
www.domain1.com => domain1.com (Wordpress)
www.domain2.com => www.domain2.com
I tried setting *.domain.com in the Domains tab, I tried all of the suggested directives in the Content and Advanced tabs' custom configuration fields, and nothing seems to have any effect.
I also have set up a few websites with subdomains of domain1.com that point to different paths and work correctly. How can I catch all the subdomains apart from these and redirect them properly?
Any help would be greatly appreciated!
I have multiple websites set up with multiple domains and I'm trying to redirect every subdomain to it's main domain, like this:
*.domain.com => domain.com
The problem is that no matter what I do all the subdomains apart from www get redirected to one domain:
w.domain1.com => w.domain1.com
w.domain2.com => w.domain1.com
w.domain3.com => w.domain1.com
...
Only www stays at the correct domain, but doesn't redirect... except for Wordpress websites:
www.domain1.com => domain1.com (Wordpress)
www.domain2.com => www.domain2.com
I tried setting *.domain.com in the Domains tab, I tried all of the suggested directives in the Content and Advanced tabs' custom configuration fields, and nothing seems to have any effect.
I also have set up a few websites with subdomains of domain1.com that point to different paths and work correctly. How can I catch all the subdomains apart from these and redirect them properly?
Any help would be greatly appreciated!
Customer support service by UserEcho
Additional Info: The "[::]" part is for IPv6.
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!
But the way you described above has worked for me right now.
You add "*.domain.com" to the domains of the site, you want to catch all subdomains for.
Subdomains you have added to another site will NOT be catched by that wildcard entry (checked that).
Make sure that you click the button "apply changes" at the bottom of that page.
For doing that, you have to create a new site and add the alias domain i have mentioned above. You will use this site only for redirecting. In this site, you add the following line in the "Custom Settings" box in the "Advanced" section:
I just wonder why adding a *.domain.com in the same website and a conditional rewrite in the Custom Configuration doesn't work...