How to access addon domain on cPanel hosting via URL when the root hosting domain is hosted on another host

7,149

Solution 1

You should be able to access it via http://IPADDRESS/~cpanel_accountname/addon_domain_directory

so it would look something like http://123.456.789.000/~matt/addondomain

UPDATE:. https://au.godaddy.com/help/preview-your-website-3950

Solution 2

Accessing websites via IP is not desirable and not supported by most good hosts.

It's considered a good practice for security savvy shared web hosts not to allow accessing content via the IP address of the server via mod_userdir, this is because mod_userdir has some security concerns. More information about this below.

SOURCE

The mod_userdir module that is responsible for this URL functioning is quite insecure and increases the risks of attacks on your account. We are concerned about users' security and use only the best security practices. Due to this, mod_userdir as well as the temporary URL is disabled on our shared servers.

SOURCE

mod_userdir allows accessing a user's homepage using the temporary URL with the /~user/ syntax, like http://ipaddress/~user where 'ipaddress' may be replaced with the server's hostname or any domain name that is resolved to the server you wish to check the content on.

Having mod_userdir enabled poses considerable security risks and disadvantages:

  1. Usernames are exposed - it is possible to access different websites hosted on the server via the same domain name (servers IP address or servers hostname) replacing the /~user/ part only (e.g., http://ipaddress/~user1, http://ipaddress/~user2, http://ipaddress/~user3, etc.) what makes hosted accounts more vulnerable to hacking attacks.

  2. When the mod_userdir module is used for accessing a website, the traffic is added to the total of the users through which visitors access the website but not to the bandwidth usage of the user who is a real website owner.

  3. mod_userdir should be disabled for root access in order to make the server protected from modification by non-root users, thus, you need to include a "UserDir disabled root" into your configuration.

As you may know, we tend to introduce the latest technology in order to protect your account and data all the time. The mod_userdir module is currently disabled on our shared servers that allows us to increase the security level and decrease chances of your account as well as server from being hacked. This is in line with our highest security standards and lets us provide you with the level of security you expect from us.

Also, if its shared hosting without a dedicated IP you would be you would be required to use /~username/addon-domain/, or however that host has setup the process, assuming that they have it enabled in the first place.

The correct way...

The correct way would be to ensure that you have added the addon domain to the cPanel and then either update the DNS A record to the IP address of the server hosting the addon domain, or use the name servers recommended by the web host hosting that server. The rest, should work... but it can take 1 hour, or 72 hours for the internet to update the records... it's not instant. So, if you added, this and that, and have not waited for this long... then there may not be anything wrong, other the fact you haven't waited long enough.

If you want to check the server configuration without waiting for the DNS to propagate across the web, you can edit your operating systems host file.

Solution 3

There is one issue with above ~username method if you are using Wordpress or other similar CMS. it breaks the absolute urls and render the page unusable without css, images and javascript.

One more method for this issue is to edit the host file and redirect your addon domain you created with cPanel to IP address of your site.

e.g. 121.12.12.12 www.example.com

Now clear the system DNS cache, this will solve the css, image, js breaking issue.

How to edit host file on MacOS

  1. Open Terminal
  2. Type sudo nano /etc/hosts and then hit return.
  3. Enter your administrator password and then hit return.
  4. Append ` ' to the file.
  5. Save the file and exit.
  6. Clear the cache. Reload the page. Hurray!!
Share:
7,149

Related videos on Youtube

kimbekaw
Author by

kimbekaw

Updated on September 18, 2022

Comments

  • kimbekaw
    kimbekaw over 1 year

    I've GoDaddy cPanel hosting account. The main domain is registered with GoDaddy and I've cPanel hosting. Main domain is hosted on other host and using other host's nameserver. I'm trying to add addon domains on this GooDaddy cPanel account. I've setup addon domains with file and db etc.

    My situation is somewhat similar to this one Registered domain on GoDaddy, pointed to Cloudflare - cannot Addon domain to my hosting, But I didn't get any error during adding addon domain.

    I've two questions:

    1. How do I access these addon domains to test if it's setup correctly. Normally it's accessible via http://example.com/addon-domain.com But in my case the main domain is hosted elsewhere so it will not work.

      • http://x.x.x.x/addon-domain.com doesn't work either.
    2. 2nd question is, will it work at all or I've to change main domain's DNS back to GoDaddy?

    • kimbekaw
      kimbekaw almost 8 years
      As Simon pointed out and I tried on some other account, accessing website via IP address doesn't work on GoDaddy. Unless someone knows how to access it via IP I think the answer to my question is that it's not possible.
  • kimbekaw
    kimbekaw almost 8 years
    Tx Steve. This is what I was looking for. Unfortunately this doesn't work for me. With the above url format it shows "File not found (404 error) If you think what you're looking for should be here, please contact the site owner." It's a WordPress site. I uploaded my own index.html just to make sure that files are there but still doesn't same error. I've used the cPanel name which it shows on cPanel and same with IP address. So no mistake there. am I missing something else?
  • kimbekaw
    kimbekaw almost 8 years
    Tx Simon, you might be right that GoDaddy might not be supporting website access via IP address. Can someone confirm it?
  • Steve
    Steve almost 8 years
    What happens if you just go to 123.456.789.000/~matt ?
  • Steve
    Steve almost 8 years
    I beg to differ. In fact most good hosts make this available as a way to work on a site either before a domain is registered or before changing nameservers. For sure it is not a long term way to access a site, but there is no problem using it as a temporary URL - if there is I am interested in hearing it.
  • Steve
    Steve almost 8 years
    It seems like most things GoDaddy, (ask about my dedicated server experience some day) they do it differently. I have added a link to a page about previewing sites.
  • Simon Hayter
    Simon Hayter almost 8 years
    @Steve Your welcome to differ but your wrong. Using the IP method as you mentioned exposes the clients username. Furthermore Google index's sites accessible by IP address, unless the site uses canonical links then the website could face issues with duplicate content. For security and indexing purposes its considered a bad practice. Using the host file as suggested is considered a best practice for access sites not yet propagated, or ones that are down due to DNS issues.
  • Steve
    Steve almost 8 years
    I think you misunderstand me Simon, it is never something you would publish, just something you would give to a designer or use yourself to create the site. Anyone who uses it 'in production' would be mad.
  • Simon Hayter
    Simon Hayter almost 8 years
    A designer like myself would just add 192.168.1.1 example.com to their host file, or they host the development site in a local sandbox. There's no reason for hosts to add this feature, by default... its not secure. There is no way of enabling, or disabling such a feature in the default cPanel dashboard, you'd have to block direct access to the IP address via the .htaccess which many do not know how to do. While this may seem like a good feature for advanced users, it is not for the majority normal users. Good security savvy hosts block this feature for many reasons, it's not needed period.
  • Simon Hayter
    Simon Hayter almost 8 years
    There's no way of not publishing the IP method, this is because mod_userdir is either enabled, or disabled by the host. I've added more to my question, as I said, IP method is not a preferred method, and consider a bad practice for lazy people who cba to edit host file :)
  • kimbekaw
    kimbekaw almost 8 years
    Tx Steve, Preview works for me, it's not straight forward but it helps me to see the website at least.
  • Steve
    Steve over 6 years
    Apart from the fact that this question is over a year old and has an accepted answer, your solution will only work if the hosting service allows temporary URLs, but most don't