I'am using VirtualDocumentRoot to have multiple domains and subdomains. Everything goes well until someone tries to reach my server by IP or an non-existing domain. For example 10.10.10.10 wich results into an 404 Not Found error. Maybe someone out there can help me find an solution to redirect non-existing domains or IP to my main domain www.example.com?
Let me be clear: non-existing subdomains are being redirected but non-existing domains are not.
HTTPD.CONF:
<VirtualHost *:80>
ServerName default
ServerAlias *
#www.example.com == /httpdocs/example.com/www/
VirtualDocumentRoot /httpdocs/%-2.0.%-1/%-3
</VirtualHost>
/httpdocs/example.com/.htacces:
# Rewrite all non-existing subdomains to www.
RewriteCond %{HTTP_HOST} example\.com$
RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [R=301,L]
RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [R=301,L] In /httpdocs/.htacces (webroot folder) – WhiteFang Jan 12 '14 at 17:57