On one ip hanging several sites. The task is this: you need from any non-existent subdomain (123123.site1.com, or qwe111.site2.com, or * .site3.com) to redirect 301 to the main domain of the desired site.
111.site1.com - leads to site1.com
222.site1.com - leads to site1.com
111.site2.com - leads to site2.com
33dsd.site2.com - leads to site2.com and so on.
Now if you specify a non-existent subdomain, we fall into the default settings and error 404 (htaccess in this case is not readable - AllowOverride None). If you put AllowOverride All help it in determining the target domain where to get?
How to do this and what to change in the settings so that there are no problems with the sites?
Default:
<VirtualHost *:81> ServerAdmin webmaster@localhost <Directory /> Options +FollowSymLinks Indexes AllowOverride None </Directory> <Directory /var/www/> Options Indexes +FollowSymLinks AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
The apache2.conf file already has individual settings for each site.