Rewrite Rule and 502 Server Error

#1
Hi,

I am deployed Litespeed on the Google Cloud Platform.

The one weird behavior I am seeing is that whenever I rewrite redirection as below the 502 error occurs:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

However, if I change the rewrite rule as shown below, it works:

RewriteCond %{HTTP_HOST} ^12\.34\.56\.78 [OR]
RewriteCond %{HTTP_HOST} ^www.example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Does anyone have a clue why it happens? (First one is from the official instruction document, and It does not work)
 

serpent_driver

Well-Known Member
#3
This one works.

Apache config:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
 
Top