WordPress Multisite SSL htaccess - wordpress

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.

Related

https to http redirecting

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]

http to https multisite 301 redirect

I have a multisite (wordpress) consisting of 21 sites. Some are sub domains and some are URLs.
I'm now going to move the entire multisite from http to https.
What do I add to the .htaccess file?
http:// www. example .com
http:// www. example .nl
http:// www. example .de
http:// no. example .com
http:// fi. example .com
To make it even more difficult I need to move and redirect the http:// www. example .nl domain to a directory on the primary domain like https:// www. example .com/nl/
Any ideas?
Thanks
You can try following rules
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.nl [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/nl/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Force Cloud Flare Flexible SSL on Wordpress with exception of feed

I'm using Cloud Flare Flexible SSL. i want to force SSL for all site except rss feed.
I've tried to do it with the code bellow but got ERR_TOO_MANY_REDIRECTS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Any solution?
If your rss feed is an alias like yourdomain/rss just make the pagerule on Cloudflare side to not redirect to https:
Rule http://yourdomain* --> Automatic Https Rewrites - Off
On the wordpress side in the .htaccess file:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/rss
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Clouflare will not redirect to https, but your Apache with wordpress will do.

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.

htaccess redirect not redirecting all pages

I am trying to implement an htaccess redirect and it is partially working. It will redirect the root domain http://oldsite.com/ to http://newsite.com/. However, when I try and do more such as http://oldsite.com/eng it will not redirect. Here is my htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]
This is from a wordpress site that had two domains that pointed to the same folder on the server (same wordpress instance). We now want to phase out the old domain so whatever link you go to on http://oldsite.com/ will redirect to the correct part of http://newsite.com/.
You should try and check for the old host before doing the redirect. If it's on the same server it will cause problems without it.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite.com [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

Resources