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!

Subdomain inside public_html

Discussion in 'Bind/DNS/Nameserver' started by toplisek, Aug 24, 2017.

  1. toplisek

    toplisek Well-Known Member

    Joined:
    Jan 7, 2010
    Messages:
    130
    Likes Received:
    7
    Trophy Points:
    68
    When I add Subdomain into public_html it is seen all content also inside main domain.

    Example:
    mySUbdomain.example.com/user/ID

    When I check also main domain like example.com/user/ID it will be also the same content as it is inside public_html.

    How to solve this as
    main domain like example.com/user/ID should not be seen but all PHP and MYSQL should be functional.
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

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

    You will need to update your custom rewrite rules in the .htaccess file under the public_html directory so they do not apply the sub-directories beneath it, or setup a rule in the .htaccess file in the subdomain's document root that ignores the .htaccess entries in the parent directory. You can find discussion of the specific rules to use on a URL such as this:

    .htaccess mod_rewrite - how to exclude directory from rewrite rule

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

    toplisek Well-Known Member

    Joined:
    Jan 7, 2010
    Messages:
    130
    Likes Received:
    7
    Trophy Points:
    68
    Is there also php INI settings that it prevents such mode without HTACCESS?
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

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

    There are no PHP settings to change in this case since the rules are coming from Apache's Mod_Rewrite module.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. toplisek

    toplisek Well-Known Member

    Joined:
    Jan 7, 2010
    Messages:
    130
    Likes Received:
    7
    Trophy Points:
    68
    As I understand it will be possible to place rewrite inside public_htm folder but dangerous as it will be consequence for the subdomain and main domain.

    If I have SUBdomain like
    example.mymaindomain.com

    Which rule inside htaccess is the best as I do not like to create a loop that will also time out?

    Example inside SUBdomain folder which will be without any loop that will also time out:
    RewriteEngine On

    RewriteRule ^
     
    #5 toplisek, Sep 1, 2017
    Last edited: Sep 1, 2017
    cPanelMichael likes this.
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