So I bought an SSL for my website, and to redirect the HTTP to HTTPS, I use the following
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
It works great. No problem. But the issue is when I do some basic Speed Tests & SEO test, theres always an error saying things similar to "disable redirect for better speed, seo".
But If i delete .htaccess redirect, there would be issues with HTTP/HTTPS
How can i solve this problem? Is there any other way to make the SSL work without redirecting?
Just In Case Information; I use Godaddy Linux Server.
Thanks in advance.
use this code in your .htaccess file to solve SSL problem
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
if RewriteEngine already "On" then no need to "On" again. I hope this will work perfectly.
Related
here is my .htaccess file:
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The problem is when I add this rule to my .htaccess file and reload the site it said me "too many redirect" and the site doesn't work. Why? How can i change https to http? I want to do this change only for a few week but i don't know how. Thanks
EDIT:
I change the code to this:
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
but it still doesn't work
Try:
RewriteCond %{HTTPS} !^off$
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Or:
RewriteCond %{SERVER_PORT} ^443$
RewriterRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If that doesn't work, the browser is probably stopping it from redirecting back to http. Or, the browser is redirecting back to HTTPS after the redirect to HTTP, and the loop starts there.
Anyways, it is a very bad idea to redirect https to http. If an ssl cert is your issue, you can get one from LetsEncrypt for free :) For localhost, you can create your own self signed cert, and trust it in your pc.
You should actually be redirecting from HTTP to HTTPS usually, because security is needed.
This is my htaccess code for redirecting non securing site to secure. but its not working.
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Our website is historylearning.com and as you can see the site is non secure. Our site is hosted on OVH server and using Cloudflare . The site is built with Typo3 CMS .
How to configure the HTTPS properly for the website? Is there anything to check on either on OVH hosting or on Cloudflare?
Thanks
You could be missing an exclamation mark before "on" and change http to https in the third line.
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This is doing the opposite of what you want, if https is on it will redirect to http. If you change it to the following it should work:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Please have a look at Cloudflares Summary of Page Rules Settings, especially "Always Use HTTPS"
I'm having trouble getting these redirects to work under all conditions. I'm hoping I can fix it with .htaccess but there may be something mucked up with the way I'd previously tried to force redirects through my host's control panel.
Anyway, olddomain.com/whatever, with http:// or https:// and with or without www should permanently redirect to https://www.newdomain.com/whatever.
At one point I had everything except https://olddomain.com redirecting properly. Now I've broken it and I'm just getting the too many redirects error.
I believe both domains have a Let's Encrypt certificate attached to them. The old domain doesn't need to be secured if that makes a difference.
According to https://serverfault.com/a/728957, you can use this snippet to help redirect users to a https://www of the site.
RewriteEngine On
# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Hope that helps!
I know guys this question has been asked many times but believe me I have tried all the solutions in the other questions without any results.
As mentioned in the title I want all my http requests to be converted into https requests, and I want to use .htaccess file to do this so this is what I have tried so far:
#https redirect
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
But this gives me nothing my site is not being redirected from example.com to https://example.com
What am I missing here ?
As worked out in a lengthy communication via chat the issue was that the redirection rules were coded after (below) other internal redirection rules, so never got applied.
Moving the http to https redirection rules up solved the issue.
I have forced a ecommerce site to be always in https, due to some issues with having only specific urls triggered as secure. I have used the following in my .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.vshoen.com/$1 [R,L]
But now my problem is all external links without www in the url open in https as well for some reason. Most of the time its not a problem but there are a few specific links that need to simply be http://url.com instead of http://www.url.com and for in this case they are not loading as its trying to open them as https://url.com
I was hoping there would be a resolution to this, this is a wordpress site if that makes any difference.
Thanks in advance.
Try this:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]