Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Addon Domain issue

Discussion in 'Bind/DNS/Nameserver' started by KimberlyPA, Mar 29, 2018.

Tags:
  1. KimberlyPA

    KimberlyPA Member

    Joined:
    Mar 29, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pennsylvania
    cPanel Access Level:
    Website Owner
    Ok, I have a question and need a fix. I have three domain names to be hosted on one account. All three have nameservers set correctly in google. I use ver 68 build 21 of cpanel through my hosting company. The main domain (ex: example.com) is set up and running a site fine. Now, when I add another domain, say ex. example2.com, that will have an entirely different site to run and the third, say ex. example3.com to have its own site too. I have asked my hosting company how to fix the problem I will state here in a moment, they tell me to fix it in a script. I don't have any script to do so.

    So, the addons are made, I added example2.com. I created one-page sites through Site Publisher so something is in the directories. Same with example3.com. Now the problem is when you type example2.com or example3.com into the browser, it shows

    example.com/example2.com and the same with example3.com. I need the address of the browser to show example2.com only. Same with example3.com. I cannot fix this and I cannot find documentation anywhere to do so. I have seen the YouTube videos and how an addon is created and did the exact same thing. But still using the URL of example2.com, I get the example.com/example2.com.

    How can this be fixed?
     
    #1 KimberlyPA, Mar 29, 2018
    Last edited by a moderator: Mar 29, 2018
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,303
    Likes Received:
    1,847
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    That shouldn't happen by default. Do you have any custom rewrite rules enabled in the .htaccess file under the public_html directory?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. KimberlyPA

    KimberlyPA Member

    Joined:
    Mar 29, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pennsylvania
    cPanel Access Level:
    Website Owner
    My problems got worse and I wasn't able to bring up any sites without typing in the entire URL, such as Example Domain (had to use https, not http). I got the issue resolved today though. It wasn't a cpanel issue at all. The support guy at my hosting company stated he could access them fine, thinking it may have to do with my laptop setup since I just got it ready for schooling and a lot of changes. So I got the notion to check them on my tablet which is Android and it couldn't access them either without typing in that entire URL. Just to test it further, I turned off wifi (Verizon DSL) on my smartphone, using it's 4G (Tracfone) and tried there and the domains came up just as they should, typing in just example.com. So, got into my modem admin and went through all the settings and just changed one thing and saved it (added a password is all). Now they work on my wifi just fine. I can't believe it was some stupid setting within my modem holding them back. But thank you for checking. Now I just got to figure out how to add some features, like a perl guestbook and other things. I need a manual.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,303
    Likes Received:
    1,847
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm glad to see you were able to solve the issue. Thank you for sharing the outcome.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. KimberlyPA

    KimberlyPA Member

    Joined:
    Mar 29, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pennsylvania
    cPanel Access Level:
    Website Owner
    I hope this reopens the thread as the issue popped back up. I checked through a couple ways to check and both my dsl and 4G were again showing the main account before the second and third domain names again. example.com/example2.com (I'll call this a dual name) for instance. When I had the problem, the hosting guy renamed the .htaccess file to .htbackup, but then I had that modem problem and by fixing the modem problem example2.com came up properly. So I check today after the dual name showed up again, the .htaccess file is back. So I rename it .htbackupnew and clear the cache on my browser and the domain name come up properly as example2.com. You mention about custom rewrite rules in the .htaccess file. Here is the entire .htaccess file:
    Code:
    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php56” package as the default “PHP” programming language.
    <IfModule mime_module>
      AddType application/x-httpd-ea-php56___lsphp .php .php5 .phtml
    </IfModule>
    # php -- END cPanel-generated handler, do not edit
    
    #Weebly Additions Start
    ErrorDocument 404 /w_api/Handler.php
    
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} !^bc2xp.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTPS}:s (on:(s)|off:s)
    RewriteRule ^/?(.*) http%2://bc2xp\.com/$1 [L,R=301,NE]
    
    Options
    RewriteEngine on
    
    RewriteCond %{REQUEST_URI} !-f
    RewriteRule ^ajax/(.*)$    /w_api/Handler.php [L]
    
    RewriteBase /
    RewriteRule ^$ index.html [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /w_api/Handler.php
    
    #Weebly Additions End
    
    --------

    Weebly is the website builder I have on my example.com main site. I use two other site builders for my example2.com and example3.com. I am not great at coding for the .htaccess file, but the guy at the hosting company said it needs to be reworked as it seems to be causing the redirect to example.com. I can code COBOL and html, but this is not something I know about.

    The code above "#Weebly Additions Start" was not in the original .htaccess before (that backup is still on the server that I can view it).

    Any help or a place where I can learn more about how to do proper coding for the .htaccess file?
     
    #5 KimberlyPA, Apr 1, 2018
    Last edited by a moderator: Apr 1, 2018
  6. KimberlyPA

    KimberlyPA Member

    Joined:
    Mar 29, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pennsylvania
    cPanel Access Level:
    Website Owner
    Now, from reading, 301 are redirects. Two lines above have the R=301 in them. Ok, I individually # each line with the 301 in them and tried, after clearing cache and in the first line #'ed it gives me the hosting company's 404 page for each of the three domains.

    So I un # that line and # the other, this allows me to access my maindomain but the addons are sent to the hosting company 404 page.

    I have not found any site in my search where someone had the exact same problem, so finding a way to fix the .htaccess isn't easy. I just want to type in my addon domains by name and have the browser address show them only (addon.com an addon2.com), not maindomain.com/addon.com or maindomain.com/addon2.com.

    The individual subfolders for the addons do not have their own .htaccess files.

    I'm still searching for an answer as well all over the web.
     
  7. KimberlyPA

    KimberlyPA Member

    Joined:
    Mar 29, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pennsylvania
    cPanel Access Level:
    Website Owner
    I have found a quick fix, but it will not allow other things to work in the addon domains.

    I added this to the very top, above it all, of my .htaccess file:
    Code:
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^(www\.)?addon1\.com
    RewriteCond %{HTTPS}:s (on:(s)|off:s)
    RewriteRule .* - [L]
    RewriteCond %{HTTP_HOST} ^(www\.)?addon2\.com
    RewriteCond %{HTTPS}:s (on:(s)|off:s)
    RewriteRule .* - [L]
    
    Now, I can pull up all three sites and their own domain name shows in the address line by themselves as addon1.com not maindomain.com/addon1.com. Now, I know that any rules below do not apply to them. I added the line for HTTPS due to them having ssl and just copied it from the line where it is for the main domain. I can type in https://addon1.com and it shows up as secured. As the addon sites won't really need ssl for anything I'm doing with them, this setup is okay for now.

    I understand from what I read, that to do anything different for the addon domains, I will need to put a .htaccess file in their own directories.

    Now, I want to put a 404 document for each addon, so, is it possible to just have a .htaccess with the line:

    ErrorDocument 404 /error/Handler.php

    (providing 404 page is in error folder that I create within the addon domain folder) and

    nothing else on the .htaccess?

    Will that work?
     
    #7 KimberlyPA, Apr 1, 2018
    Last edited by a moderator: Apr 1, 2018
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,303
    Likes Received:
    1,847
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Here are a couple of third-party URLS you may find helpful when configuring your .htaccess files:

    How can I configure an .htaccess of a sub-directory so that it COMPLETELY ignores the .htaccess of any parent directories?
    How to ignore .htaccess file from a parent directory?

    Actually, you'd just upload the "404.shtml" page directly to the document root of the addon domain name or primary domain name. Or, simply use the "Error Pages" option in cPanel. There's no need to add an entry to the .htaccess file.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice