Forum Moderators: phranque
I've got a working Apache server, and to view my page you would type http://XXX.XXX.XXX.XXX
You would then come to the index.html file in my DocumentRoot. I have also got an account at dyndns.org where I get a DNS (http://example.nu) for my IP (Static DNS)...
I now have sub folders on my server DocumentRoot (i.e. http://XXX.XXX.XXX.XXX/subfolder1/, http://XXX.XXX.XXX.XXX/subfolder2/). Can I make a DNS sort of thing to go directly to one of these sub folders?
I.e.
http://subdomain1.example.com (would take me to subfolder1)
http://subdomain2.example.com (would take me to subfolder2)
If I had even further subfolders(i.e. subfolder1/minifolder1), I could type http://subdomain1.example.com/minifolder1/
Is this possible? If so, how much does it cost? Can it be done for free?
I'm open for suggestions...
Tell me if you don't understand my explanation.
Thanks!
//Tommy
[edited by: jdMorgan at 2:19 am (utc) on Jan. 8, 2004]
[edit reason] de-linked, examplified [/edit]
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@mydomain.mine.nu
# DocumentRoot /www/docs/subdomain1
# ServerName subdomain1.mydomain.mine.nu
# ErrorLog logs/subdomain1-error_log
# CustomLog logs/subdomain1-access_log common
# <Directory /www/docs/subdomain1>
# Options Indexes FollowSymLinks
# AllowOverride None
# Order allow,deny
# Allow from all
# </Directory>
#</VirtualHost>
You can make a number of subdomains using the same format, but you must remember the following:
1. The lines must be uncommented, remove the #
2. The directories referenced must exist
3. You must have dns entries for the subdomain your using.
Try adding this in the VirtualHost directive. Change the directory path to your DocumentRoot. Also if your using Windows the DocumentRoot must be something like "c:/program files/Apache/htdocs" , be sure to include the quotes.
<Directory /www/docs/mydomain/subdomain>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Go to dyndns.org and look at the FAQ's for wildcard DNS or Subdomains. There should be information to set it up in your account.
1. A subdomain delegation feature (available with the purchase of an Account Upgrade) that turns your hostname into a subdomain handled by your own DNS server.
2. A wildcard option allowing *.yourhost.dyndns.org to point to yourhost.dyndns.org
Which one's the one I'm looking for?
//Tommy
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.yourhost\.dyndns\.org$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.yourhost\.dyndns\.org(.*) http://yourhost.dyndns.org/$1/$2 [PT,L]
Your subdomains will be subdomain.yourhost.dyndns.org, and will serve transparently from yourhost.dyndns.org/subdomain.
The subdomain and folder name will be the same.
That's off the top of my head quickly, so let me know if there's a syntax problem there...
[edited by: jdMorgan at 2:19 am (utc) on Jan. 8, 2004]
[edit reason] de-linked [/edit]
<VirtualHost *.80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/sub
ServerName sub.example.com
ErrorLog logs/1-error_log
CustomLog logs/1-access_log common
<Directory /var/www/html/sub>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
[edited by: jdMorgan at 5:11 pm (utc) on Jan. 8, 2004]
[edit reason] examplified URLs [/edit]
Try this modified virtualhost directive:
<VirtualHost *:80>
ServerAdmin webmaster@yourhost.dyndns.org
DocumentRoot /var/www/html
ServerName yourhost.dyndns.org
ServerAlias *.yourhost.dyndns.org
ErrorLog logs/1-error_log
CustomLog logs/1-access_log common
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.yourhost\.dyndns\.org$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.yourhost\.dyndns\.org(.*) http://yourhost.dyndns.org/$1/$2 [PT,L]
</VirtualHost> ... and give it a whirl. If my syntax is right, sub.yourhost.dyndns.org should serve from /var/www/html/sub.
[edited by: jdMorgan at 2:20 am (utc) on Jan. 8, 2004]
[edit reason] de-linked [/edit]
<VirtualHost *:80>
ServerAdmin webmaster@yourhost.dyndns.org
DocumentRoot /var/www/html
ServerName yourhost.dyndns.org
ServerAlias *.yourhost.dyndns.org
ErrorLog logs/1-error_log
CustomLog logs/1-access_log common
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.yourhost\.dyndns\.org$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.yourhost\.dyndns\.org(.*) http://yourhost.dyndns.org/$1$2 [PT,L]
</VirtualHost> [edited by: jdMorgan at 2:21 am (utc) on Jan. 8, 2004]
[edit reason] de-linked [/edit]
Hope this helps in some way.
[edited by: jdMorgan at 9:10 pm (utc) on Jan. 8, 2004]
[edit reason] Do not post real domain names - thanks [/edit]