Search code examples
mod-rewriteapache2freebsdvirtualhostwildcard-subdomain

problem with subdomains in apache22+freebsd8


I have domain somedomain.net which is linked to some IP 123.45.67.89

I need to have such subdomains:

  • sub.somedomain.net - points to IP 123.45.67.89
  • *.sub.somedomain.net - catch all *. in sub.somedomain.net

in apache.conf I have such record:

<VirtualHost *:80>
  DocumentRoot "/www/somedomain.net"
  ServerName somedomain.net
  ServerAlias www.somedomain.net
  ServerAlias sub.somedomain.net
  ServerAlias *.sub.somedomain.net

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^(.*)\.somedomain\.net$
  RewriteRule ^(.*)$ http://somedomain.net [R,L]
</VirtualHost>

But I have 404 error while opening http://sub.somedomain.net

In my domain admin-panel I have such records:

somedomain.net IN A 123.45.67.89
somedomain.net IN NS1 ns1.domain-seller.com.
somedomain.net IN NS2 ns2.domain-seller.com.
sub IN A 123.45.67.89
*.sub IN A 123.45.67.89

Where is my mistake? Thanks!

PS: I'm using dedicated server, so I can do any changes in configurations.


Solution

  • somedomain.net IN A 123.45.67.89
    somedomain.net IN NS1 ns1.domain-seller.com.
    somedomain.net IN NS2 ns2.domain-seller.com.
    sub IN A 123.45.67.89
    *.sub IN A 123.45.67.89
    

    That looks wrong. If that's a bind file, you need to write sub.somedomain.net and not sub only.