Apache 通配符sub.domain.tld重定向到domain.tld/sub

Apache 通配符sub.domain.tld重定向到domain.tld/sub,apache,apache2,subdomain,wildcard-subdomain,Apache,Apache2,Subdomain,Wildcard Subdomain,我目前在apache上有一个通配符子域: <VirtualHost xxx.xxx.xxx.xxx:80> DocumentRoot /home/web/domaine.tld/www ServerName domaine.tld ServerAlias *.domaine.tld VirtualDocumentRoot /home/web/domaine.tld/%1 CustomLog /var/log/apache2/domaine.tl

我目前在apache上有一个通配符子域:

<VirtualHost xxx.xxx.xxx.xxx:80>
    DocumentRoot /home/web/domaine.tld/www
    ServerName domaine.tld
    ServerAlias *.domaine.tld
    VirtualDocumentRoot /home/web/domaine.tld/%1
    CustomLog /var/log/apache2/domaine.tld/access.log combined
    ErrorLog /var/log/apache2/domaine.tld/error.log
</VirtualHost>

DocumentRoot/home/web/domaine.tld/www
ServerName域.tld
ServerAlias*.domaine.tld
VirtualDocumentRoot/home/web/domaine.tld/%1
CustomLog/var/log/apache2/domaine.tld/access.log组合
ErrorLog/var/log/apache2/domaine.tld/error.log

并且需要将任何子域(如sub.domain.tld)重定向到domain.tld

您可以通过.htaccess使用重定向

Redirect http://sub.domain.tld http://domain.tld