Redirect https://www to https

Hello!

Would really appreciate some help with this.

Have tried to redirect the typed address to https without www. It works great with www. example, http:// example, example and http:// www.example. Problem is that it doesn´t work if you write https://www. example – you get the typed address without a redirection (SSL problem). Is it possible to fix this somehow?

The code below was found on this forum and used in the htaccess file, but it didn´t had a noticeable impact in this case. The url in wordpress general settings is set to https without www. No custom url in use.

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.(.
)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

Understand that it is preferable to provide the website url, but would prefer not to make it public. Hope that maybe someone can provide some advice even without that information.

Thanks in advance!

Hello, and Welcome to the InfinityFree Forum!

If you are using WordPress for your website, you do not need to insert the .htaccess rewrite code. You just have to change the URL in the WordPress administrative dashboard to use HTTPS and to not use WWW.

Also, it would help us a lot if you were to provide your URL. I understand that hiding your URL may be best for you, but it’s harder to help you out if you don’t provide your URL.

3 Likes

Sure, that should be an easy fix!

On the last line in the snippet you shared, simply replace http:// with https:// and it should work.

6 Likes

Hello!

Thanks for your reply, both of you.

Admin, I followed your description but unfortunately it made it a bit worse. It didn´t worked with any www combination after the change – previously, it was only https://www that didn´t redirected. I did also test the new code, but with a change of the row order, as below. That resulted in the same outcome as before. In other words, https://www didn´t worked but all the other www combinations resulted in a redirection.

The htaccess file has the code according to your suggestion for now, but it would obviously be great if you have some other idea? Can of course pm you the url if it helps.

The code exactly as you suggested the adjustment:

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]

The code as you suggested the adjustment but with the change of row order:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Something just came to mind.

Are you using a custom domain or a free subdomain?

If you are using a free subdomain, then https://www.(your subdomain) will always show an SSL warning because it’s not covered by the system SSL certificates. And to be able to redirect a website that’s requested with a HTTPS, you must have a valid SSL certificate.

It’s not possible to setup SSL on www.(your subdomain), so there is no way to solve that I’m afraid.

4 Likes

Thanks for your reply!

Using a non custom url.

There appears to be a possibility to get an SSL certificate through a Wordpress plugin. Could this be a good solution in this case – a possibility to SSL connection even if someone types https://www?

Should add that this type of issues is unfortunately not within my area of knowledge.

2 Likes

No, there’s 0 possibility. WordPress plugins can never touch server configurations.

7 Likes

Thanks to all of you who has contributed with information in this issue!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.