Forum Moderators: phranque

Message Too Old, No Replies

subdomains and how to make them work?

         

keenax

5:23 pm on Jul 15, 2007 (gmt 0)

10+ Year Member



So I activated the wildcard for subdomains in the zone file
and I added the folowing in httpd.conf:

<VirtualHost _ip_:80>
ServerAdmin webmaster@example.com
DocumentRoot /home/example/public_html
ServerName www.example.com
ServerAlias *.example.com
ErrorLog logs/example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

now I am using this .htaccess for subdomains to work

rewriteEngine on
rewriteCond %{HTTP_HOST} .
rewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
rewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com [NC]
rewriteRule ^/(.*) /%1/$1 [L]

What I succeeded so far is that everything I type as a subdomain goes directly to the main domain.

If I have a sublfolder and I type subfolder.example.com/subfolder it goes to the existing subfolder. Now I don't know what I did wrong, but if somebody knows some tips it would be great.

System:CentOS
The domain is hosted on a GD dedicated server

[edited by: jdMorgan at 7:02 pm (utc) on July 15, 2007]
[edit reason] example.com [/edit]

jdMorgan

3:57 pm on Jul 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Take a look at your VirtualHost configuration, and make sure it exactly matches one of the examples given in the Virtual Host examples for common setups [httpd.apache.org] at apache.org. Start with a standard configuration of three or fewer hostnames, get it working, and then modify it if needed. Once modified and working, expand it to the number of vHosts actually needed. The basic idea is to reduce the number of "unknown factors" while debugging your setup.

Generally, there is no need to specify IP address and port number unless those differ between the vHosts, and specifying them often causes problems. See also the notes on invoking the default server when the requested hostname cannot be found.

Jim