0

I have a shared hosting on Apache web server with cpanel access to my hosting account the primary domain abc.in is used to access the public_html folder on which the site files are stored.

I have added a few domains that are not related to abc.com through cpanel add on domains. They are namely def.com ghi.com jkl.com

so my file system for the domains on shared hosting will be like this

/public_html/ files or directories for abc.in

add on domains are also on

            /public_html/def.com/
            /public_html/ghi.com/
            /public_html/jkl.com/

so you might have understood the working system..

def.com website files are stored in sub directory in public_html folder as shown above

similarly

ghi.com website files are stored in sub directory in public_html folder as shown above

jkl.com website files are stored in sub directory in public_html folder as shown above

now the issue is i need to force https /ssl on primary domain abc.com

the ssl is issued only for abc.in and support.abc.in only

not valid for www version of abc.in and support.abc.in

more over as per my seo knowledge a website should redirect to only one version of website.

that is either www version or non www version

so i have redirection enabled for abc.in in cpanel

so whether it is www.abc.in or abc.in it will go to abc.in only

as discussed earlier ssl is only issued for abc.in and support.abc.in only

now i want to force ssl to entire domain of abc.in and support.abc.in

i have tried cpanel redirection for this,but multiple redirection made a loop and website un accessible.

i have found a .htaccess rewrite here Force HTTPS and strip WWW without receiving Cert error

but enabling it made all the add on domain hosted in sub directories redirecting to abc.in in ssl version.

So i need only ssl access to abc.in and support.abc.in

and i will need separate rules (http) for add on domains and i will be adding more add on domains later.

So i need a htaccess configuration that is generalized for this scenario,so that i can configure the add on domains to use their ssl if needed in future and rules for add on domain that i add in future.

I request the super webmasters and programmers to give some generic/custom generic configuration of htaccess for my situation.

As i am web designer i have no knowledge on htacess rewriting and i am fairly new to this.

Any one who understand the issue,please provide your valuable input.Your response is very important for me.Thank you.

please do explain the code that solves my problem,so that i can customize it later if needed.

Community
  • 1
  • 1
  • I suggest you reformat your question ASAP or it is likely to get closed. You know, paragraphs and all that. – chappjc Dec 12 '13 at 16:54

1 Answers1

0

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(support\.)?abc\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks for quick reply but it does not work for me,i am using www redirection in cpanel for my problem.Now i want to force https only for entire primary domain,remaining domains(add on domains) can be http only for now but i may need to make them https in future if each domain gets its own ssl certificate i will use it then if needed.So i need a generic solution explaining how to accomplish this,your instant help is appreciated and hope you will help soon for my problem. – user3096066 Dec 12 '13 at 17:20
  • That rule is exactly doing what you've described in question i.e. only for domains: `support.abc.com` and `abc.com` it will redirect all the URIs to `https` if it is not already `https`. – anubhava Dec 12 '13 at 18:04
  • Also you need to specify clearly what URL you tried that didn't work for you. – anubhava Dec 12 '13 at 18:05