The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to allow ONLY specific domain to access a directory?

Discussion in 'Bind / DNS / Nameserver Issues' started by 123bear, Apr 24, 2015.

  1. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    hi.
    I want the directory domain.com/community to be avilable ONLY trough the domain domain.community - entering domain.com/community directly will cause 404, but accessing domain.community will result 200 .

    THANKS!
     
    #1 123bear, Apr 24, 2015
    Last edited by a moderator: Apr 24, 2015
  2. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    hi. please don't shoot - i'm a newbie.
    there is a directory of a domain. i want to set that directory to be viewable only through another domain.
    How to do that?

    Thank you!

    (please correct me FIRST before blocking. thanks.)
     
  3. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    this version was previously posted by mistake - i can't edit it.
     
    #3 123bear, Apr 25, 2015
    Last edited: Apr 25, 2015
  4. LostNerd

    LostNerd Well-Known Member

    Joined:
    Mar 12, 2014
    Messages:
    258
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Hastings, East Sussex, UK
    cPanel Access Level:
    Root Administrator
    Twitter:
    Your best bet is to use the .htaccess file. Get it to check the host. If the host is domain.com, redirect to /index.php for example. However if the host is community.domain.com, do nothing. :)
     
  5. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    Can you please tell me EXACTLY what write, so I can do "copy-paste"?
    To my best understanding; you mean the .htaccess that in the domain.com/Directory.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you provide a specific example (using fake domain names) of the preferred behavior?

    Thank you.
     
  7. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    but i already did...
    domain.com has a hosting package. 2nd domain has his own directory at the same hosting package at domain.com/example .
    I want:
    to block direct access to domain.com/example with 404 error
    allowing access only to fakedomain.con , points to that exact same directory, with 200 o.k
     
  8. 24x7ss

    24x7ss Well-Known Member

    Joined:
    Sep 30, 2014
    Messages:
    271
    Likes Received:
    16
    Trophy Points:
    18
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You can forbid the access to specific directory by putting below in htaccess:

    Options -Indexes

    You can also redirect 403 error page to your custom error page by putting below in htaccess:

    ErrorDocument 403 /errors/forbid.html
     
  9. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    Will A domain be able to access it? or will it be forbidden for ALL?
     
    #9 123bear, Apr 28, 2015
    Last edited: Apr 28, 2015
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Have you considered simply adding the addon domain name with it's document root in the account's home directory instead of the public_html directory? Otherwise, the following third-party URL explains how to configure this:

    https://my.bluehost.com/cgi/help/498

    Thank you.
     
  11. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    thanks for your help.

    To my best understanding: only "public_html" & it's subdirectories are visable to search engines - isn't moving "directory" to the root, out of "public_html"; will make my 2nd site invisible to search bots??

    I don't know what i'm doing wrong: the script of bluehost doesn't work (yes i've change it accordingly).
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    No, that is not accurate. The document root is configured in the Apache configuration file, so Apache knows where to look for the content associated with the domain name.

    Thank you.
     
  13. 123bear

    123bear Member

    Joined:
    Apr 24, 2015
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    cPanel Access Level:
    Website Owner
    Thanks, it works great.

    case closed.
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page