LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-22-2014, 12:59 PM   #1
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
2 domain names pointing to same index.html file


I would like to have 2 different domain names point to the same 'index.html'.
Question #1. Is that possible and is it permitted?

Then I would like the 'index.html' file to determain which domain name called it and branch appropreably.

I've been reading over on Stackoverflow

I'm confused about some terminalogy.
Question #2. Should I use either of these?
Code:
NAME [{$_SERVER['SERVER_NAME']}]";
"HTTP_HOST [{$_SERVER['HTTP_HOST']}]\n"
Or something like this?

Quote:
..... set the domain name as an environment variable in the apache2 virtual host:

# Virtual host
setEnv DOMAIN_NAME example.com
And read it in PHP:

// PHP
echo getenv(DOMAIN_NAME);

Last edited by Dafydd; 06-22-2014 at 01:02 PM.
 
Old 06-22-2014, 01:17 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
first of all, domains do not point at 'index.html', they point at an IP address, it is then up to the configuration of the web server ie:(apache, IIS, lighthttp) to determine how to handle the domain request by serving the contents of a 'document root' folder specified in the server configuration.

a virtual host block in the apache conf would look something like this
Code:
<VirtualHost x.x.x.x:80>
DocumentRoot /home/user/content/www
ServerName x.gotdns.com
<Directory "/home/user/content/www">
allow from all
allowoverride all
Options +Indexes
</Directory>
</VirtualHost>
where

Code:
/home/user/content/www
is a folder that acts as the root of your web-site's tree structure.

As for whether or not it's permissible to have multiple domains share the same document root, this is not only possible but such commonplace as there are ways of doing this with 'alias' directives, and there php scripts (such as Drupal) that are even coded to be able to take advantage of it to make one code base behave like a theoretically infinite number of discrete sites based on domain/subdomain.

example (extract from above)
Code:
ServerName x.gotdns.com
ServerAlias y.gotdns.com
the 'index.html' is merely a convention of the default html document for a server to present when serving the contents of a folder on the server, if one is not present, the directory contents are listed instead (unless rules prevent that)

as for $_SERVER, that is PHP code, which is a server side programming language, which would be necessary to add such logic to a program. and would be placed in an 'index.php' rather than an 'index.html', the php file extension tells the server to process the file as a server-side script rather than simply handing the contents of the document wholesale to the browser.



hope this helps

Last edited by frieza; 06-22-2014 at 01:23 PM.
 
1 members found this post helpful.
Old 06-22-2014, 05:32 PM   #3
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
This helped mucho.
I now know that I know less than I thought I knew.

Let me absorb some of this and try to write some code. Be back= in a couple 3 days.
Thanks
Dave
 
Old 06-23-2014, 03:03 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
no problem ^^
setting up a web server isn't really as hard as it first seems, not that it's exactly easy, but when it comes down to it it just takes a good amount of patience and planning to know what you intdend to do with your machine. How you configure your server can then be determined based on how you intend to use the server.

Note, most default apache servers on Linux machines (at least the ones packaged in the distribution's repositories) come configured a default server with a 'document root' of /var/www, /var/www/html or some other variant of such, you COULD use that as is, but that would require ROOT access to modify the files on the server, which is why I usually create virtual hosts with their 'document root' in a user's home directory, as this allows easier ftp/sftp access to the server without having to do any complicated permissions work etc... and is more secure overall to not be running web scripts etc with root access.
 
Old 06-25-2014, 05:40 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Is stackoverflow talking about host headers? A way to have multiple FQDN's pointing to a single IP address?
 
Old 06-26-2014, 12:06 AM   #6
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
Jefro....
A lot of my problems in searching out the code education I need is the lack of my knowledge of acronyms used in the computer coding world.

So?

I've seen lots of text about host headers. What are they? And what are 'FQDN's'?
 
Old 06-26-2014, 03:15 PM   #7
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by Dafydd View Post
Jefro....
A lot of my problems in searching out the code education I need is the lack of my knowledge of acronyms used in the computer coding world.

So?

I've seen lots of text about host headers. What are they? And what are 'FQDN's'?
FQDN stands for 'Fully Qualified Domain Name'
which contains it's exact location in the DNS hierarchy
eg: example.com myhost.example.com or www.google.com etc...
 
Old 06-26-2014, 03:20 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Sorry, I re-read your question and I was confused.


You can have a million domain names point to a web server that offers a page. That page being any name you wish.

A FQDN is only a way to translate a text name to an IP address for the web. www.linuxquestions.org is being sent over the internet as an IP address (and possibly a port number.) Try 75.126.162.205 in your browser address line. It should result in LQ.

The server doesn't care what name was used to request the page unless host headers were used. That is where I was backwards. You simply want two URL's to point to your single web server. It should work fine with no intervention on your part. As long as your FQDN's or local host names all resolve to an IP and when you use that IP instead of a name the web page you created works then all is OK.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where to upload index.html file hemanthm17 Linux - Server 7 06-13-2012 09:48 PM
I have a domain pointing to my DNS server. Do I need NS records in the zone file? ohlookpie Linux - Server 1 05-03-2012 09:37 AM
Lighttpd - how to name the index.html of additional domain? satimis Linux - Server 1 04-18-2011 12:22 PM
Script to create index.html file seashell11 Programming 4 09-25-2010 10:25 AM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration