Score:0

How can I show the subdirectory of a server as an index based on domain used to connect to it?

eg flag

I have 2 domains running in the same directory off the same IP (Via a CNAME record in each's DNS)

the directory shows this in the apache index:

index of /

domainOne.com/
domainTwo.com/

This is shown when you visit the site via it's IP address.

However, I want domainOne.com/html/ to be shown IF the domain is Domain One, and domainTwo.com/html if the domain used to connect is Domain Two.

I tried putting a subdirectory in the CNAME record so it points to 12.34.56.789/domainOne.com/html/ but that obviously didnt work, since CNAMEs can only direct to IPs, not specific folders, which sucks.

Is this possible? If it is, it would make my life SO much easier.

(PS, Im doing everything in my httpd.conf file, I dont have config files per domain, since I couldnt figure out how to connect my domains to AWS... and so now Im so low as to use CNAME records...)

Basically I want to know if I can do this with the rewrite engine if possible.

And honestly, the only reason I want to do this, is so the sites are accessible from the debug address at one location in the same directory, and so that the sites can access resources inbetween eachother.

This is all Ive managed to come up with, and of course, it doesnt work.

RewriteEngine on

<If "%{HTTP_HOST} == 'domainOne.com'">
    Alias "/" "${DocumentRoot}/domainOne.com/html"
</If>

See the site here to understand what I mean at the start (https://mistersircode.com/)

(If the site doesnt have the index in the future, thats likely because I fixed my issue.)

Score:2
us flag

You need to configure separate virtual hosts for each of your domains in Apache.

Mister SirCode avatar
eg flag
I tried using vhosts in the configuration file, but they werent working oddly. Is it because Im connecting the domains using a CNAME?
us flag
DNS has nothing to do how Apache handles virtual hosts indicated by HTTP `Host` header.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.