How Do I Set Up a Subdomain with a Separate Webhost and Domain Registrar

.htaccessdomain-name-systemhostingsubdomain

I have looked at all sorts of solutions online and come up with nothing. I cannot ask the webhost for help because it's not my hosting account; I am setting it up for a client. My client has a domain name through some domain registrar, and web hosting through iPower. For sake of example, let's say their domain name is domain.com. I want to point sub.domain.com to domain.com/sub in a transparent way (so that a visitor would type sub.domain.com and their address bar would continue to show that as the domain, never visibly switching to domain.com/sub).

Tools I do not have:

  • access to httpd.conf
  • SSH access to the hosting server
  • the ability to contact iPower support, since I don't have clearance to access the information (billing and security question) they require of me when submitting a support ticket

Tools I do have:

  • indirect access to the domain registrar's control panel (I send the admin an email and he changes it according to my wishes, but he is not knowledgeable about networking or DNS or anything)
  • access to iPower hosting control panel
  • access to .htaccess files
  • FTP access to the iPower public_html directory and all subdirectories

The domain registrar's control panel offers the usual ability to set CNAMEs, MX records, A records, etc. The iPower hosting control panel has a sort of "ghost" of the domain in their domain control panel as well, and though it tells me the domain is registered elsewhere, it allows me to input things like DNS records and subdomains.

So far, I have the domain set up on the registrar with an A record pointing to the server's IP address. I tried setting up a similar A record on the iPower end of things, to no avail. Same with a Subdomain, and a CNAME. It only ever sends requests to sub.domain.com directly to the files in the public_html folder (the same as what's displayed at domain.com. I tried the mod_rewrite rule presented HERE, but it seemed to have no effect. I also tried the mod_rewrite rule presented HERE, but it brought me a 500 Server Error when I tried it (I'm sure I modified it incorrectly, but I don't know what I got wrong). When I had a corresponding A record and subdomain configured in the iPower domain control panel, instead of directing visitors to the root site, it displays a page that says "Directory has no index file. Browsing this site or directory without an index file is prohibited." even though there is an index file in that folder. There are a lot of files in that folder (Drupal installation), and accessing domain.com/sub directly produces the working website.

So. All that said, does anyone have any straightforward directions for me to follow? Please remember that I only have access to the .htaccess files and the domain control panels, but lack access to the Apache .conf files, so I can't do anything like ServerAlias.

I know this shouldn't be this complicated, but nothing I've tried from any of the directions or articles I've found which are applicable to my situation have helped.

I am mildly embarrassed to be having this problem, since I have had my own web hosting with multiple domains and subdomains for several years — but I've been spoiled by the cPanel way of doing things, and having my domains and files hosted and managed in the same place. I can write code in a few different languages, and I can fix broken computers and other technology, but I can't figure out how to configure a webserver. Frustration.

Thank you in advance for your help and advice. I often find the answers I need just by searching and lurking here and there on this network of Q&A sites, but in this case, I have apparently been missing something.

Best Answer

1) just a note. You can't set up sub.domain.com without registrar's help, unless domain.com is running your own DNS server. I understand, however, that it is already done.

2) things that must be in the existing Apache httpd.conf, or you are out of luck:

a) RewriteEngine enabled. b) Apache accepting requests for sub.domain.com

If both those things are OK, then I suppose you should be able to do rewrite via .htaccess like this:

RewriteEngine On

RewriteCond %{HTTP_HOST}  domain.com [NC]
RewriteCond %{HTTP_HOST}  !^$
RewriteRule ^/sub(.*) http://sub.domain.com/$1 [R=301,L]

Details may vary depending on what your underlying web pages have configured for site URL and whether you want to use single sub.domain or more, etc.

Related Topic