I have a website and have recently installed an SSL certificate. I want all links to the site to always redirect to the secure site without www, as I have made the SSL applicable to non-www.
Furthermore, I have WHMCS in the backend and want to redirect the example.com/whmcs
page to example.com/client-portal
as I have a third party plugin that links with whmcs.
What should I insert in my .htaccess
file and in what folders should I insert the file? Can I specify everything from root and if this is the case, how do I force WHMCS to be happy with this?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
Edit
The good news is that I have solved the first part of the problem. All URLs now redirect to the non-www https website. The code that solved this issue was supplied by @John Conde - thanks John!
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
My next goal is to have example.com/whmcs
redirect to example.com/client-portal
.
...but without redirecting example.com/whmcs/admin
to example.com/client-portal/admin
. In other words, /whmcs/admin
should not redirect.
I have tried the following solution but without success. I'll appreciate it if you guys can help.
RewriteCond !^example\.com\/whmcs\/admin
RewriteCond ^example\.com\/whmcs$
RewriteRule https://example.com/client-portal [R=301,L]
My intention was that this causes /whmcs
to redirect but not for /whmcs/admin
to redirect.