Forum Moderators: phranque

Message Too Old, No Replies

Multiple homepages?

Multiple homepages/adresses

         

Spde

1:12 am on Jan 6, 2004 (gmt 0)

10+ Year Member



Hi,
Just wondering, would it be possible to have multiple hompages on the same server? I'll explain myself:

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]

fwwebs

2:33 am on Jan 6, 2004 (gmt 0)

10+ Year Member



You can do this with VirtualHost directives. At the bottom of your httpd.conf your should see something like the following:

#
# 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.

Spde

9:49 am on Jan 6, 2004 (gmt 0)

10+ Year Member




#VirtualHost *:80

#<VirtualHost *:80>

3. You must have dns entries for the subdomain your using.

Instead of *:80, what should I write? An IP or the subdomain?

DNS entries? What's that? (:)) How do I know if I have DNS entries for the subdomain?

fwwebs

11:38 am on Jan 6, 2004 (gmt 0)

10+ Year Member



Leave it as VirtualHost *:80

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.

Spde

10:01 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



Hmmm... dyndns.org had very little about subdomains. I found two things that might be of interest:

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

bakedjake

10:07 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



option 2. and you'll need a rewrite rule in your virtualhost directive. umm... Try this:

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]

Spde

10:49 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



I'm terribly sorry, but I'm VERY new to Linux (Started out about a week ago ;) ). Could you please write step for step on how I should edit my files with your information.
Sorry!
I'm very eager to learn how to do it!

//Tommy

bakedjake

11:01 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It goes within the <virtualhost> directive. Between the start and end tag.

Spde

11:26 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



Okay... And what information in it should I replace with my own info?

BTW: Where I type <directory /www/docs/subdomain1>... should I put the path in quotes?

//Tommy

bakedjake

11:28 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



OK. Let's try this a different way. :)

Post everything between:

<VirtualHost yourhost.dyndns.org:80>

...and...
</VirtualHost>

And we'll help you figure it out.

Spde

11:32 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



Okay, here goes:

<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]

bakedjake

11:37 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



OK, per the TOS, you'll want to make your URLs generic. Let's continue with convention and use yourhost.dyndns.org as the base domain, and sub.yourhost.dyndns.org as the subdomain.

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]

Spde

11:41 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



THX!
I'll try it right now... Can I MSG you privately and have you test it? Cause it doesn't seem to work from my that's in the same LAN as the server...

//Tommy

bakedjake

11:58 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



oops, trailing slash problem. change it to this - this should work:

<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]

karelj

1:39 pm on Jan 8, 2004 (gmt 0)

10+ Year Member



Hey.. I was having a similar problem with using dynu.com
I had example.dynu.com and example2.dynu.com. Both pointed to my WAN ip address, both had port 81 redirects due to my ISP blocking port 80. My router was setup to direct port 81 requests to the LAN ip# of the server and Apache was set to sniff on port 81. But like you, my virtual host configs did not seem to work.. example2.dynu.com never resolved to it's own directory.
It was discovered that the port forwarding redirection to myip:81 killed the domain name recognition for Apache, so I just set example2 to be forwarded to port 82, had Apache listen on 82 as well, set the virtualhost setting for example2 to 82 and now it works...

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]