https to http redirecting - http

I have a website and domain was like https://example.com. Now my domain is http://example.com. I don't want want to remove SSL certificate I will renew it after 4-5 days. So till the time how can I redirect the user from my https to http?
I tried some code in htaccess but it's not working. I am using GoDaddy hosting.
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Related

Wordpress SSL & www rewrites

Having an issue with some url rewrites.
I want to redirect all urls to https with no www
Currently I have :
1) Forces https with the (s) - working
http://example.com => https://example.com
2) Forces https with the (s) and removes www - working
http://www.example.com => https://example.com
3) Remove the www from the https with the (s) requests - failing
https://www.example.com => https://example.com
It seems as if it's not even reaching my htaccess code with an ERR_SSL_UNRECOGNIZED_NAME_ALERT
Site might be temporarily down or it may have moved permanently to a new web address.
This is what I have in my htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
The site is hosted by Host Gator and I contacted support and was told that it's impossible to set this up because the site is built with Wordpress.
That didn't seem like the right answer to me so thought I'd ask here.
Any info appreciated.
Cheers
RewriteCond %{HTTPS} off will not detect HTTPS requests, so you may want to add another rule for HTTPS requests only (with the same/similar conditions), e.g.:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Instead of adding this, you can also simplify everything with an OR condition:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>
Which means, if HTTPS is null or off OR the domain does not start with example.com, redirect to https://example.com.
Amusing that the support believes that Wordpress somehow prevents .htaccess to be used, but I wonder if your host may have certain .htaccess restrictions, preventing plugins that rely on it (e.g. BulletProof Security) to work properly.

WordPress Multisite SSL htaccess

I would like to redirect from non-https to https on my site and subdomains, but I'm having issues to solve it.
This is my setup:
www.domain.de
www.sub.domain.de
www.sub2.domain.de
www.sub3.domain.de
I can open all links by https and it works, but due duplicate content I would like to use https only.
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://domain.de/$1 [R=301,L]
this is my htaccess so far... but it redirects the subdomains to the primary domain :(
any ideas?
You can use:
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
You can use this pluging: https://wordpress.org/plugins/https-redirection/
It is a simpel way to do it, it redirect everything from HTTP to HTTPS.

http:// to https:// redirect but something is overriding it back to http://

I am trying to redirect my domain
http://atc-logistics.ie
and
http://www.atc-logistics.ie
to
https://www.atc-logistics.ie
My hosting company gave me this code for the .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS_HOST} ^atc-logistics.ie [NC]
RewriteRule ^(.*)$ https://www.atc-logistics.ie/$1 [L,R=301]
and are insisting that there this is correct and something else is causing a redirect so it keeps rebounding back to http://atc-logistics.ie. I can't see any other redirects and there are no redirect plugins (Wordpress).
Can anyone let me know if the redirect above is correct? I am really struggling and the hosting company don't seem to be able to help!
The htaccess redirect system I use is this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
And that works fine for me.
It checks if the host does not begin www. and then diverts to the www. address before then checking if the protocol is Secure and then if it is not forces redirect to the HTTPS, using the previously set HOST and URI address values.

Wordpress SSL Redirection with One Sub-Folder Exception

Sorry to ask such a total newbie question - I'm struggling with an exception to our SSL redirection rules on our Wordpress site. Basically, everything is redirecting as http to https.
Feedburner doesn't support https feeds (grr!) so I'm hoping to create an exception to prevent requests for http://domain.co.uk/feed/ being redirected to https://domain.co.uk/feed/
Our redirect rules in .htaccess look a little like this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Any and all help really, really appreciated. Thanks!
Try
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
#exclude /feed/
RewriteCond %{REQUEST_URI} !^/feed/ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
#This section is optional
RewriteCond %{HTTPS} on
#send any cached https /feed/ back to http
RewriteCond %{REQUEST_URI} ^/feed/ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
If you previously visited the /feed/ URL and were redirected, this redirect will be cached in your browser. To test that it works correctly after changing the rule, change to private browsing, or clear you browser cache.
If you think that existing clients have the same problem i.e. a cached https redirect to /feed/ you can include the optional section to send them back to http

.Htaccess rules to redirect respective HTTP links to HTTP and HTTPS to HTTPS?

First, here's the .htaccess rule I currently use:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://example.com/$1 [R=301,L]
This is great, and redirects every link of my old domain to the very respective link in new domain. That is, http://olddomain.com/1.html is redirected to http://example.com/1.html and so forth.
But it doesn't redirect https://olddomain.com/1.html to https://example.com/1.html
And just so you know I tried, below are the rules I also happened to test. Unfortunately they're creating some kind of loop, and the redirection doesn't work.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) example.com/$1 [R=301,L]
and
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule (.*) example.com/$1 [R=301,L]
So, can someone give me the rules redirect http pages to http and https pages to https? Thanks.
#if https on
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
#else
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Your HTTPS rewritecond is incorrect. Cond is a regex, not an quality test. It should be
RewriteCond %{HTTPS} !^on
The %{HTTPS} var will only ever contain on or off. Never =on, so the match fails and triggers the redirect, even if https really is on.
update
For an unconditional HTTP->HTTPS redirect you'd need to redirect to an https URL. Your version just detects if HTTPS is *OFF, then redirects to the same url, causing a loop. What you need is:
RewriteCond %{HTTPS} !^on
RewriteRule (.*) https://example.com/$1 [R=301,L]

Resources