Steven Swarts
asked on
Redirect all website traffic to https - cPanel or .htaccess
G'day guys,
I've searched for my particular query but everyone had different focus'.
What I have:
cPanel shared hosting, with legitimate SSL Certificate
What I need:
All traffic hitting http://techcare.net.au and http://www.techcare.net.au to be redirected to https://www.techcare.net.au
I need this to happen at every stage of the journey. For example I host my own support ticket system in a sub folder https://www.techcare.net.au/support/
It needs to redirect any query to www.techcare.net.au/support or to the admin page www.techcare.net.au/support/scp to secure traffic - https://www.techcare.net.au/support or https://www.techcare.net.au/support/scp
Anyone know how to do this?
regards,
Steve
I've searched for my particular query but everyone had different focus'.
What I have:
cPanel shared hosting, with legitimate SSL Certificate
What I need:
All traffic hitting http://techcare.net.au and http://www.techcare.net.au to be redirected to https://www.techcare.net.au
I need this to happen at every stage of the journey. For example I host my own support ticket system in a sub folder https://www.techcare.net.au/support/
It needs to redirect any query to www.techcare.net.au/support or to the admin page www.techcare.net.au/support/scp to secure traffic - https://www.techcare.net.au/support or https://www.techcare.net.au/support/scp
Anyone know how to do this?
regards,
Steve
Dave, can you take a quick look at this one https://www.experts-exchange.com/questions/28337944/Multiple-Websites-on-a-single-host.html?anchorAnswerId=39799310#a39799310
Try this code in your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ASKER
Is that a replacement to what Dave Baldwin gave?
Do I put that in the public_html/.htaccess or do I have to put it in every .htaccess that is on my hosting?
Do I put that in the public_html/.htaccess or do I have to put it in every .htaccess that is on my hosting?
Both versions are almost identical. The one I posted had some helpful text along with the rules. You only need to put it in the top level .htaccess for that site. All requests for any pages on that site will use the rules in the top level .htaccess.
ASKER
Thank you for the clarification Dave.
Just one more thing however.
How do I force the use of www ?? So if someone goes to http://techcare.net.au it rightly redirects to https://techcare.net.au now, but how do I force it to actually go to https://www.techcare.net.au
cheers,
Steve
P.S. I do prefer the helpful text, cleared it up a lot.
Just one more thing however.
How do I force the use of www ?? So if someone goes to http://techcare.net.au it rightly redirects to https://techcare.net.au now, but how do I force it to actually go to https://www.techcare.net.au
cheers,
Steve
P.S. I do prefer the helpful text, cleared it up a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brilliant Dave, absolutely brilliant.
Works like a charm so far, thank you very much.
that's the total package
Works like a charm so far, thank you very much.
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTP_HOST} !^www\.
# This prepends www to any direct entry
RewriteRule ^ https://www.techcare.net.au%{REQUEST_URI} [L,R=301]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
that's the total package
ASKER
Exactly what I was looking for
You're welcome, glad to help.
From http://wiki.apache.org/httpd/RewriteHTTPToHTTPS
Open in new window