Why does my force HTTPS/SSL redirect edit cause a 500 error?

Avatar
  • updated
  • Answered

Hi. I'd like to force my main domain and all subdomains to use SSL, so I inserted the following code at the top of my root .htaccess file:

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://www.kaweah.com/$1 [R,L]

Unfortunately, this edit causes all hits to my site to error out as follows:

Error 500 - Internal Server Error

An error was encountered while processing your request. Typically this is a temporary condition. Please contact the web site owner for further assistance.

Any idea where my mistake is?

Thanks!

How would you rate the customer service you received?

Satisfaction mark by kaweah 4 years ago

That did it! Thanks very much!Thanks also for the plugin tip. I'm not too worried about images and anyway I also have a Drupal-based site (self-torture).

Add a comment about quality of support you received (optional):

Pinned replies
Avatar
anonymous
  • Answer
  • Answered

Hello! I ran this by one of the senior technicians, who pointed out that you're missing escape characters on some spaces. 

(?: Comodo DCV)?$ 

should be

(?:\ Comodo\ DCV)?$ 

as spaces need to be escaped when writing .htaccess. 

While i was confirming the 500 error, the technician pointed out that, while this will force visitors to the https version of  your site, you are still going to have to worry about image links and other links using http instead of https. If you are on a WordPress site, I would suggest using a plugin like Really Simple SSL. This will take care of the .htaccess and also make sure your links are good to go. Either way, I hope that helps!

Avatar
anonymous
  • Answer
  • Answered

Hello! I ran this by one of the senior technicians, who pointed out that you're missing escape characters on some spaces. 

(?: Comodo DCV)?$ 

should be

(?:\ Comodo\ DCV)?$ 

as spaces need to be escaped when writing .htaccess. 

While i was confirming the 500 error, the technician pointed out that, while this will force visitors to the https version of  your site, you are still going to have to worry about image links and other links using http instead of https. If you are on a WordPress site, I would suggest using a plugin like Really Simple SSL. This will take care of the .htaccess and also make sure your links are good to go. Either way, I hope that helps!