SSL blocking my website - .htaccess

This morning when I try to access my website using https it says: https://--example-- is requesting your username and password. The site says: “Protected Folder”
I haven't changed nothing and in the cpanel I don't have any protected folder. Does anyone know what it can be?
Thanks
Here is my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^secure\.example2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.secure\.example2\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/secure\.example2\.com\/rent\/whitelable\.cfm\?WL\=3" [R=301,L]

Related

Correct .htaccess to redirect all https:// pages to https://www

I want to redirect all non-www pages to https://, but only the home page does so as expected. That is, http://kraftgiftbox.com will redirect to https://www.kraftgiftbox.com/ as I expect, that's ok!
But none of the sub-level page will, like https://kraftgiftbox.com/odd-shaped-boxes.html, it won't redirect to the www version.
I had a .htaccess file as follows:
RewriteOptions inherit
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://kraftgiftbox.com/$1 [R,L]
ErrorDocument 404 /404.shtml
RewriteCond %{HTTP_HOST} ^kraftgiftbox\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.kraftgiftbox\.com\/" [R=301,L]
Can someone please help me correct the code? Thanks!
The last line of rules caused that because you only capture root request by this RewriteRule ^/?$ , to achieve what you want try this :
ErrorDocument 404 /404.shtml
RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?kraftgiftbox\.com$ [NC,OR]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.kraftgiftbox.com/$1 [R=301,L]
Rules above will do both , forcing https and www as well.
Note clear browser cache then test.

Redirecting all subdomains to https via .htaccess file

In anticipation of the Google Chrome change going live on July 1, I want to make sure all the files on a site I manage redirect to https. It's an Apache server and I have the following already in the file (using a fake domain name for demo purposes):
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example.org$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.org$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.example\.com\/" [R=301,L]
As you can see above, there is a redirect from a domain I'm parking (example.org) to the main domain I'm managing (example.com). Other than that, all I want to have happen is for all pages of the site, including all subdomains to redirect to the https version of each page. For example, when someone goes to http://webmail.example.com I would like them to go to https://webmail.example.com or when an admin goes to http://cpanel.example.com, they should be redirected to https://cpanel.example.com
I like keeping www in the URL for links not in a subdomain on this site. For example, if someone goes to http://example.com/folder/file I want them to go to https://www.example.com/folder/file
The above code is located in the .htaccess file of the root folder. Do I need to have a .htaccess file in a folder for each subdomain in order to get this to work? Or am I just doing something wrong in the existing .htaccess file?

How to fix htaccess RewriteRule back reference to RewriteCond? Fix for CPANEL AutoSSL Let’s Encrypt

CPANEL with AutoSSL (Let’s Encrypt) add automatic RewriteCond to htaccess because .well-known folder and keep updating htaccess file every X minutes, so you can't delete the "well-know" lines. But with this approach they break RewriteRule back reference to RewriteCond.
# www to non-www generic
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
This example above don't work as spectated because %1 references last RewriteCond, and not the first where we filter the host with regexp.
Some fix for generic www to non-www, using variables
# www to non-www (fixed to work with CPANEL - AutoSSL)
SetEnvIf Host "^www\.(.*)$" my_domain=$1
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://%{ENV:my_domain}/$1 [R=301,L]
To bypass this problem use variable, it's not pretty but works!

.htaccess redirect http > https with 301 redirects

I have recently had an SSL certificate installed and now my entire website uses it, without errors. I had set up a redirect from http to https but realised it was using a 302 redirect. I currently use the following code which uses a 301 redirect.
Is this correct? Can I remove any part of this, or should I change any part of this?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Thank you for checking.
The first part of your code is weird, why you redirect on HTTP all and after that on https in second part :) ?
Here is my example, it is similar to yours but I don't need to change every time domain name for example if you use the same pattern on different servers + this will redirect all traffic from http to https
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/\d+.BIN_AUTOSSL_CHECK_PL__.\w+.tmp$ [NC]
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9]{32}.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
The RewriteCond %{HTTPS} on portion may not work for all web servers. My webhost requires RewriteCond %{HTTP:X-Forwarded-SSL} on, for instance.

How to redirect all pages to same page on a subdomain using htaccess?

I'm new to htaccess but i would like to do this
For example, I want to forward:
www.abc.com/page_1.html
www.abc.com/folder123/page_a.html
www.abc.com/folder123/page_b.html
to:
subdomain.abc.com/page_1
subdomain.abc.com/folder123/page_a
subdomain.abc.com/folder123/page_b
Note: abc.com (HTML) and subdomain.abc.com (on Wordpress) is on different web servers.
Thanks!
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.subdomain.abc\.com\/" [R=301,L]

Resources