Sub Website Appears On Main Domain

Discussion in 'Site & Server Administration' started by untitledstudios, Nov 1, 2016.

  1. #1
    Okay, so I have several websites hosted on the same domain.

    Let's say my main domain name is news.com and my other website is amazon.com. How can I prevent amazon.com showing up as part of news.com?

    For some reason amazon.com is found on news.com like : news.com/amazon.com To get the website up of amazon.com I have to put it in public html folder of news.com, so I'm guessing that's why. But how do I prevent it from actually being accessible there from news.com? I don't want it showing up on google as news.com/amazon or even to be accessible there.

    I hope this makes sense. To summarize, how do i prevent news.com/amazon and instead just have amazon.com
     
    Solved! View solution.
    untitledstudios, Nov 1, 2016 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    You would need a directory-level override with .htaccess to deny the existence of a REQUEST_URI matching ^\/amazon\.com\/?.*? or such, and RewriteRule to [F].

    You could also relocate the addon domain outside of the DocumentRoot, so that it's not accessible via the parent domain.
     
    zacharooni, Nov 1, 2016 IP
  3. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #3
    To be more concise, you can, for example, move the addon domain folder outside of public_html, e.g. /home/cpanelusername/amazon.com/, and get your hosting company to update the userdata mapping, and rebuild httpd.conf for you. Or, re-map it inside of cPanel > Addon Domains if it's not restricted to public_html only in WHM.

    In this way, you could not get to http://news.com/amazon.com because amazon.com/ would no longer exist under public_html where news.com is mapped to. You would then need to update any respective paths in your app to remove /public_html.
     
    zacharooni, Nov 1, 2016 IP
  4. untitledstudios

    untitledstudios Well-Known Member

    Messages:
    1,545
    Likes Received:
    99
    Best Answers:
    0
    Trophy Points:
    185
    #4
    @zacharooni much thanks for the quick response! I am a bit of a novice when it comes to the management through ftp and cpanel. So how would I rebuild the addon domains? Essentially the second website (amazon.com) which I am trying to get by itself, is just a single page website, so it doesn't have any other pages within it, so it should be relatively easy?

    edit: oh, do you mean "Document Root"? Just update that to home/amazon?
     
    untitledstudios, Nov 1, 2016 IP
  5. #5
    Yeah, if it's just a few files, just move the directory, via FTP, out from /home/user/public_html/ into /home/user/ so that your folder resolves to /home/user/amazon.com, then go to cPanel > Addon Domains, and enter the new path for amazon.com so cPanel rebuilds the Apache configuration.
     
    zacharooni, Nov 1, 2016 IP
    untitledstudios likes this.
  6. untitledstudios

    untitledstudios Well-Known Member

    Messages:
    1,545
    Likes Received:
    99
    Best Answers:
    0
    Trophy Points:
    185
    #6
    @zacharooni thank you, your help is much appreciated!
     
    untitledstudios, Nov 1, 2016 IP