1

I have tried to use the example from this wiki page -

$HTTP["scheme"] == "http" {
    # capture vhost name with regex conditiona -> %0 in redirect pattern
    # must be the most inner block to the redirect rule
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}

But when I enter this url -

http://www.domain.co.il/index.php?shop=amazon

I got redirected to

https://index.php/index.php?shop=amazon

What is the problem?

dima_mak
  • 125
  • 1
  • 7
  • The example on the wiki page is fine; the question is how you tried to use it - maybe show us a larger part of your config. – Stefan Sep 14 '14 at 18:12

2 Answers2

0

Everything works fine after removing this -

url.rewrite-once = ( "^/min/([a-z]=.*)" => "/min/index.php?$1",
        "^(.*)\.(jpg|gif|woff|tff|png|js|css|html|htm|txt)(.*)$" => "$0",
        "^/question2answer/(.+)$" => "/question2answer/index.php?qa-rewrite=$1",
       "^/$" => "/index.php"
     )
dima_mak
  • 125
  • 1
  • 7
  • But is there a way to do so with addition redirecting to "www." if there is no "www." in host? May be I need to ask a new question? – dima_mak Sep 14 '14 at 18:30
-1

This might not be the most elegant way, but it worked for us. Explicitly catches a regex match. (Note: maybe it should be "https://%1$1")

$SERVER["socket"] == ":80" {
    $HTTP["host"] =~ "^(.*)$" {
        url.redirect = ( "^/(.*)" => "https://%1/$1" )
    }
}
Nils Toedtmann
  • 3,342
  • 5
  • 26
  • 36
  • .* matches by default the complete string (greedy match), and so %0 and $0 are perfectly fine. $SERVER also adds a socket bind, which usually isn't wanted - the scheme matching is the right way. – Stefan Sep 14 '14 at 18:11