InMotion Hosting Support Center

Force https and www

Category: Ssl

InMotionFans
n/a Points
Asked:
2015-09-04 12:30 pm EST

Hits: 562
VPS 1000s
I have tried to force mydomain.com to www.mydomain.com by accessing my .htaccess file and inputting

#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301,NC]

I have also tried to force HTTPS by accessing my .htaccess file and inputting

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R,L]

When that didn’t work I tried

#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301,NC]

None of these has worked correctly. Support chat has helped as far as they can and told me to contact Managed Hosting. Managed Hosting helped me as far as they could and said to contact a Developer. Developer wants $600 to start.

If I go directly to https://www.mydomain.com it works and pages have the green lock. I type in www.mydomain.com or mydomain.com it does not redirect to https: it still goes to http:. We use Nginx as a proxy, support chat suggested that could be an issue.

Any help would be great.

You must login before you can ask a follow up question.

You must login before you can submit an answer.

TJ

Thanks for responding so quickly. The converter tool seems like it should be very helpful.

I have been battling this SSL/HTTPS change for weeks now. I am a beginner in server management and I am trying to limit the amount of outside resources we have to pay for by doing what I can myself. It seems like every step that is recommended to me involves 5 more steps and still no resolution.

Before I proceed further I wanted to know if I am on the right track..


I am trying to find the location of Nginx.conf. What I have found is;

1. I need to gain Root Access (done)
2. Then login through SSH (does my account have ssh access?),
3. Get SSH client (PuTTY?)
4. Generate SSH key – Download/Convert Key -
Ender17
6 Points
2015-09-08 09:32 am EST

OTHER ANSWERS

0

TJEdens
Staff
10,077 Points
2015-09-04 1:44 pm EST
Hello,

Thanks for submitting a question on how to Force https and www.

In order to perform these redirects you would need to put them in the nginx.conf as that will take priority over your Apaches .htaccess file. I found a neat little tool that seems to convert .htaccess redirects to valid Nginx syntax. If you need further help on this issue please do not hesitate to contact us back.

Best Regards,
TJ Edens

You must login before you can post a comment about this answer.

TJ

Thanks for responding so quickly. The converter tool seems like it should be very helpful.

I have been battling this SSL/HTTPS change for weeks now. I am a beginner in server management and I am trying to limit the amount of outside resources we have to pay for by doing what I can myself. It seems like every step that is recommended to me involves 5 more steps and still no resolution.

Before I proceed further I wanted to know if I am on the right track..


I am trying to find the location of Nginx.conf. What I have found is;

1. I need to gain Root Access (done)
2. Then login through SSH (does my account have ssh access?),
3. Get SSH client (PuTTY?)
4. Generate SSH key – Download/Convert Key -
5. Add IP address to firewall
Ender17
6 Points
2015-09-05 1:09 pm EST
Hello Ender17,

Yes, those steps are correct. All accounts have an SSH account. You will use either the main cpanel username or the root user to access the account. In this case, use the root.

Kindest Regards,
Scott M
scott
43,761 Points
Staff
2015-09-08 10:18 am EST
I have SSH / root access via Putty. I have accessed nginx.conf by inputting nano /etc/nginx/nginx.conf in to putty.

Now what? Do I input the codes on this page?

# nginx configuration
location / {
if ($http_host ~* "^example.com"){
rewrite ^(.*)$ http://example.com/$1 redirect;
}
}

and then

# nginx configuration
location / {
if ($http_host ~* "^example.com"){
rewrite ^(.*)$ https://example.com/$1 redirect;
}
}

Do I then save?
Ender17
6 Points
2015-09-08 3:35 pm EST
Hello Ender17,

Thank you for contacting us. Yes, you should just put it there and save the file. Also, it looks like you posted the same thing twice.

Thank you,
John-Paul
John-Paul
31,633 Points
Staff
2015-09-09 11:29 am EST
Like this Question?

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

Need more Help?

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!