How To Redirect my site from http to https using .htaccess?

Questions and Answers related to Domain and Web Hosting!
Daisy Watson
Junior Member
Posts: 6
Joined: Sat Jul 23, 2016 3:23 pm

How To Redirect my site from http to https using .htaccess?

Postby Daisy Watson » Sun Jul 31, 2016 8:04 am

I need an urgent help.

I got SSL for my Wordpress website. But, when I am typing with http it is not redirecting to https. What to do?

Atish Ranjan
Administrator
Posts: 288
Joined: Sat Jul 23, 2016 12:12 pm
Location: India
Contact:

Re: How To Redirect my site from http to https using .htaccess?

Postby Atish Ranjan » Sun Jul 31, 2016 8:10 am

Daisy Watson wrote:I need an urgent help.

I got SSL for my Wordpress website. But, when I am typing with http it is not redirecting to https. What to do?


Hello Daisy,

This is in trend, everyone is moving to https. It's good to choose this.

First thing, go to your Wordpress dashboard. Then Settings => General

replace http with https in Wordpress Address and Site Address

Save the settings!

Now for redirecting from http to https, go to your .htaccess file which you can access using cPanel or even from your Wordpress dashboard if you are using Yoast SEO plugin.

Once .htaccess file is opened. Add this code at the top and save the file

Code: Select all

#Rewrite everything to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


Note: before editing .htaccess, keep its backup with you.

Hope this helps!
Atish Ranjan
Administrator

Mikey
Junior Member
Posts: 8
Joined: Sun Jul 31, 2016 8:12 am

Re: How To Redirect my site from http to https using .htaccess?

Postby Mikey » Sun Jul 31, 2016 8:14 am

I had the same query. glad I found this here. Thanks for the solution.

it worked well for me.

Thanks.
Mikey.
I am mikey

Mikey
Junior Member
Posts: 8
Joined: Sun Jul 31, 2016 8:12 am

Re: How To Redirect my site from http to https using .htaccess?

Postby Mikey » Sun Jul 31, 2016 8:16 am

One more issue I am getting since I moved to https. I cannot see green lock with my URL which I can see in this site's link and other https sites. How to get this green lock?
I am mikey

Atish Ranjan
Administrator
Posts: 288
Joined: Sat Jul 23, 2016 12:12 pm
Location: India
Contact:

Re: How To Redirect my site from http to https using .htaccess?

Postby Atish Ranjan » Sun Jul 31, 2016 8:59 am

Mikey wrote:One more issue I am getting since I moved to https. I cannot see green lock with my URL which I can see in this site's link and other https sites. How to get this green lock?


Hello Mikey,

It is because some of your website's content is still loading with Http.

The pages which still loads some of http content won't have https green lock.

First check your home page, and look at the images' link, and see if they are still loading with http. Or, you can just edit those posts on your blog's home page, and reinsert them, it will work.

if you have some ad codes, then do check them as well.

Once all the content loads with https, you will be able to see the green lock with your URL.

When I had changed to https, I got the same issue. But, now all well.

Hope this helps!
Atish Ranjan
Administrator

Mikey
Junior Member
Posts: 8
Joined: Sun Jul 31, 2016 8:12 am

Re: How To Redirect my site from http to https using .htaccess?

Postby Mikey » Mon Aug 01, 2016 8:07 pm

One more issue is coming with me.

Suppose my domain is example.com which is running fine on https://example.com

but, when I type www.example.com, it doesn't get redirected to https://example.com. Due to this, Security alert page comes and I am losing traffic.

What is the solution?
I am mikey

Atish Ranjan
Administrator
Posts: 288
Joined: Sat Jul 23, 2016 12:12 pm
Location: India
Contact:

Re: How To Redirect my site from http to https using .htaccess?

Postby Atish Ranjan » Mon Aug 01, 2016 8:13 pm

Mikey wrote:One more issue is coming with me.

Suppose my domain is example.com which is running fine on https://example.com

but, when I type www.example.com, it doesn't get redirected to https://example.com. Due to this, Security alert page comes and I am losing traffic.

What is the solution?


What a question, and that too at the right moment. I was having the same issue. I tried a lot but nothing worked. Then, I added this code at the top of my .htaccess file

Code: Select all

#Force redirect www to non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.24x7forum\.com [NC]
RewriteRule ^(.*)$ https://24x7forum.com/$1 [L,R=301]


This code simply redirects www to non-www URL. This worked for me quite well.

Note: replace the domain name in the code

Hope this helps.
Atish Ranjan
Administrator

Mikey
Junior Member
Posts: 8
Joined: Sun Jul 31, 2016 8:12 am

Re: How To Redirect my site from http to https using .htaccess?

Postby Mikey » Mon Aug 01, 2016 8:18 pm

Atish Ranjan wrote:
Mikey wrote:One more issue is coming with me.

Suppose my domain is example.com which is running fine on https://example.com

but, when I type www.example.com, it doesn't get redirected to https://example.com. Due to this, Security alert page comes and I am losing traffic.

What is the solution?


What a question, and that too at the right moment. I was having the same issue. I tried a lot but nothing worked. Then, I added this code at the top of my .htaccess file

Code: Select all

#Force redirect www to non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.24x7forum\.com [NC]
RewriteRule ^(.*)$ https://24x7forum.com/$1 [L,R=301]


This code simply redirects www to non-www URL. This worked for me quite well.

Note: replace the domain name in the code

Hope this helps.



I just copied and pasted this code and replaced your URL with mine. And, placed at the top of my site's htaccess file.

To my surprise it worked.

Thank you so much, Atish.

Since I am not techie guy i was worried about it. glad I found this topic here.

have a great day.
I am mikey

Atish Ranjan
Administrator
Posts: 288
Joined: Sat Jul 23, 2016 12:12 pm
Location: India
Contact:

Re: How To Redirect my site from http to https using .htaccess?

Postby Atish Ranjan » Mon Aug 01, 2016 8:20 pm

Mikey wrote:I just copied and pasted this code and replaced your URL with mine. And, placed at the top of my site's htaccess file.

To my surprise it worked.

Thank you so much, Atish.

Since I am not techie guy i was worried about it. glad I found this topic here.

have a great day.



I am glad that your problem is fixed now.

Cheers!
Atish Ranjan
Administrator


Return to “Domain and Web Hosting”

Who is online

Users browsing this forum: No registered users and 1 guest