[Solved]Rewrites not preserving the URL scheme

#1
Hi Folks

Seems there's something I'm not understanding about rewrites in LS. These are config file rewrites set in the console.

I have an http and https listener both pointing at the same virtual host.

Everything works as expected under http. Under https, all the static file rewrites are being redirected to http. This causes Insecure Contents warnings in some browsers.

Here is a typical rule:

RewriteRule ^/s/(.*) /files.mysite/img/site/$1 [NC,L]

So the input is:

https://mysite.com/s/myimage.png

And the rewrite is:

http://mysite.com/files.mysite/img/site/myimage.png

I would expect the scheme to be preserved in the rewrite. This seems to be a LS issue -nothing on Google to suggest that this happens on Apache. Is it something to do with using the same VH for http and https? Would very much appreciate guidance as this could be a pig to debug...
 

mistwang

LiteSpeed Staff
#2
The rewrite rule wont check or change http or https, the problem must be in the html code referencing the image file with absolution URL like http://... regardless being served by http or https. use relative URL without "http://mysite.com" should fix this.
 
#3
Thanks for responding.

> the problem must be in the html code referencing the image file with absolution URL like http://...

I was being dim, but in a different way. I'd introduced a rule higher up the chain which was having unexpected side-effects. I've fixed the bug and all is well.

Sorry for troubling you...
 
Top