Trying to convert urls to https://example.com
I managed to convert the following:
http://www.example.com
http://example.com
but not:
https://www.example.com
My code so far:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I tried:
RewriteCond %{HTTPS_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
But that was a no go. Also for some reason the first code set works fine in all instances in Chrome but not in Safari or Firefox (even after clearing the cache and restarting the apps).
Any help would be appreciated. Thanks.
Related
I need to redirect https://www to https://
I've tried every possible snippet of code I could find online to do that over .htaccess
The best one seemed:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
But it's not working for me.
Nothing I do has any effect. If I type https://www.danielleb.com/ - that's where I remain.
How can I make this work?
This is what I am using and it works fine for redirecting https://www. to https://
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
Currently I'm using http://example.com but I want redirect all to https://www.example.com
I read several topics here and tried quite a few solutions to this but nothing worked for me.
My last try was this:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
When I'm using this code I can see this:
enter image description here
But it gives me this message also:
The page isn’t redirecting properly. Firefox has detected that the
server is redirecting the request for this address in a way that will
never complete.
Can you help me with this?
Replace example with your domain and try
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Looks to me that you're also trying to force www. You can do both by using this in your .htaccess:
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Place this rule to the top of your .htaccess file and make sure you clear your cache before you test it.
I have this .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
I want to modify .htaccess, that site always show https in url. I tried
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
this don't work. I tried also
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
but in this case I got This webpage has a redirect loop error..
Help me to configure that please.
The only reason why this code not working
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
this is what the certificate give you cloudflare or something other similar service, when you hasn't direct control to your ssl certificate.
I had such problem with ssl from cloudflare, and I solve that with
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)$ https://domain.com/$1 [L]
I just need to add 'https' remove 'www' in every case:
user input in browser -> url output
www.example.com -> https://example.com
http://www.example.com -> https://example.com
https://www.example.com -> https://example.com // NOT WORKING
I'm using following code:
RewriteEngine on
RewriteCond %{http_host} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,NC]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [R,L]
For whatever reason it works for the first two cases, but I can't make it work for the last one.
I couldn't even solve the last case isolated trying it e.g. like:
RewriteEngine on
RewriteCond %{https_host} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,NC]
Any help very appreciated!
i'm sure this is a duplicate but here the code i use:
RewriteEngine on
#This removes the www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [L,R=301,NC,QSA]
#This makes redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I have referred all the related questions and tried the answer given, but it's not working for my site.
In my .htaccess file, I have written below code to redirect non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Are there any settings in Joomla that need to be set so it will use the .htaccess file?
This is what I use -
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
The differences are minor but should make it work. This works completely outside the scope of Joomla, you shouldn't have to do anything to Joomla for this to work.
You can put the following into your .htaccess to do this:
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
this works for me all the time