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.

Subdomain inside public_html

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

  1. toplisek

    toplisek Well-Known Member

    Joined:
    Jan 7, 2010
    Messages:
    67
    Likes Received:
    2
    Trophy Points:
    58
    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 Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,371
    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.
     
  3. toplisek

    toplisek Well-Known Member

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

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,371
    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.
     
  5. toplisek

    toplisek Well-Known Member

    Joined:
    Jan 7, 2010
    Messages:
    67
    Likes Received:
    2
    Trophy Points:
    58
    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