hrace009

Well-Known Member
Dec 24, 2013
75
10
8
Root
cPanel Access Level
Root Administrator
Twitter
Hello,

I have main domain (DOMAIN.LTD) root directory at /home/user/public_html/
and sub domain (SUB.DOMAIN.LTD) root directory at /home/user/public_html/sub.domain.ltd/

and from WHM, i force it to use public_html as document root.

at the main domain, i have .htaccess like bellow:
Code:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
   # First rewrite to HTTPS:
   # Dont put www. here. If it is already there it will be included, if not
   # the subsequent rule will catch it.
   RewriteCond %{HTTPS} off
   RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

   # Now, rewrite any request to the wrong domain to use www.
   RewriteCond %{HTTP_HOST} !^www\.
   RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
this htaccess will force to use https://www.domain.ltd

The problem is, that htaccess will override root directory from SUB.DOMAIN.LTD
and it will force the SUB.DOMAIN.LTD to be https://www.sub.domain.ltd
and will make auto SSL fail to obtain certificate for https://sub.domain.ltd
is there a way to fix this problem without unforce to use public_html ?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
  • Like
Reactions: hrace009

hrace009

Well-Known Member
Dec 24, 2013
75
10
8
Root
cPanel Access Level
Root Administrator
Twitter
Hello,

You will need to edit your custom Mod_Rewrite rules to ensure they do not apply to your subdomain. You may find the following URLs helpful:

mod_rewrite - Apache HTTP Server Version 2.4
How to stop sub directory inheriting parent's htaccess rules
How to prevent .htaccess inheritance?
SSL wildcard use with subdomains
Excluding a subdomain from .htaccess mod_rewrite rules?

Thank you.
can you give me sample costum Mod_Rewrite rules from my case?

Thank You
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

I've moved this thread to our Workarounds and Optimization forum to allow for user-feedback on custom Mod_Rewrite rules. You may also want to post to a forum such as StackOverflow for specific advice on custom rewrite rules.

Thanks!
 

hrace009

Well-Known Member
Dec 24, 2013
75
10
8
Root
cPanel Access Level
Root Administrator
Twitter
Hello,

I've moved this thread to our Workarounds and Optimization forum to allow for user-feedback on custom Mod_Rewrite rules. You may also want to post to a forum such as StackOverflow for specific advice on custom rewrite rules.

Thanks!
or if not posible hope cpanel can give ability to edit main directory root path, since i think it will good if all web data in public_html with it's own webroot path
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
or if not posible hope cpanel can give ability to edit main directory root path, since i think it will good if all web data in public_html with it's own webroot path
Instructions on changing the document root for primary domain name associated with an account are found at:

Changing DocumentRoot of all sites

Thank you.