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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Denying access for Sub Domain only

Discussion in 'General Discussion' started by Fred90, Sep 25, 2017.

  1. Fred90

    Fred90 Member

    Joined:
    Aug 24, 2017
    Messages:
    9
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    Ontario, Canada
    cPanel Access Level:
    Root Administrator
    I like to block access to a subdomain to everyone except for one IP. I cannot drop an .htaccess file in this folder as the domain itself requires access.

    www.domain.com has access to the following directory
    /home/domain.com/public_html/photos

    sub.domain.com points and to this same directory
    /home/domain.com/public_html/photos

    If I place the following into that directory this blocks everything for both domains accessing it.

    order allow,deny
    deny from all
    allow from xx.xx.xx.xx

    Is there another options I can use so that www.domain.com ignores it and sub.domain.com reads it.
     
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    335
    Likes Received:
    95
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You may be able to achieve what you want using a mod rewrite rule (perhaps using HTTP_REFERER ?)

    I would suggest you test for the domain with no prefix, and also the domain with the www prefix
    OR
    use an IF NOT sub.domain.com ......

    Hope this helps

    mod_rewrite - Apache HTTP Server Version 2.4
     
  3. Fred90

    Fred90 Member

    Joined:
    Aug 24, 2017
    Messages:
    9
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    Ontario, Canada
    cPanel Access Level:
    Root Administrator
    That is what I just finished adding. And tried it, all seems to be working. Just need to check the connecting server that has access.

    Thanks!
     
    cPanelMichael likes this.
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm glad to see you were able to find a suitable solution.

    Thank you for updating us with the outcome.
     
Loading...

Share This Page