1

Craft 2.6

I have a site that's been running for some time and now when trying to do a password reset or account verification error I get the following message.

enter image description here

I found this stack exchange thread Where Brad Bell said:

Every time we've been able to investigate this issue so far, it has been because of either .htaccess stripping querystring params behind the scenes (i.e. no [QSA] flag on the rewrite rule), or the equivalent in nginx-land.

This is good, however I don't know what the The equivalent of [QSA] is in nginx.

Here is my nginx config file relevant bits with sensitive stuff removed.. any tips?

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.domain.ca/before/*;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.domain.ca;
    root /home/forge/www.domain.ca/public;


    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/www.domain.ca/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }


    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }



    # Localized sites, hat tip to Johannes -- https://gist.github.com/johanneslamers/f6d2bc0d7435dca130fc

    # If you are creating a localized site as per: https://craftcms.com/docs/localization-guide
    # the directives here will help you handle the locale redirection so that requests will
    # be routed through the appropriate index.php wherein you set the `CRAFT_LOCALE`

    # Enable this by un-commenting it, and changing the language codes as appropriate
    # Add a new location @XXrewrites and location /XX/ block for each language that
    # you need to support

    location @enrewrites {
        rewrite ^/en/(.*)$ /en/index.php?p=$1? last;
    }

    location /en/ {
        try_files $uri $uri/ @enrewrites;
    }

    location @frrewrites {
        rewrite ^/fr/(.*)$ /fr/index.php?p=$1? last;
    }

    location /fr/ {
        try_files $uri $uri/ @frrewrites;
    }

    # For WordPress bots/users
    location ~ ^/(wp-login|wp-admin|wp-config|wp-content|wp-includes|(.*)\.exe) {
        return 301 https://wordpress.com/wp-login.php;
    }

}


# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.domain.ca/after/*;


Got a partial hacky fix working. in nginx config I changed this:

location @enrewrites {
    rewrite ^/en/(.*)$ /en/index.php?p=$1? last;
}

location /en/ {
    try_files $uri $uri/ @enrewrites;
}

location @frrewrites {
    rewrite ^/fr/(.*)$ /fr/index.php?p=$1? last;
}

location /fr/ {
    try_files $uri $uri/ @frrewrites;
}

to

location @enrewrites {
    rewrite ^/en/(.*)$ /en/index.php?p=$1?$query_string last;
}

location /en/ {
    try_files $uri $uri/ @enrewrites;
}

location @frrewrites {
    rewrite ^/fr/(.*)$ /fr/index.php?p=$1?$query_string last;
}

location /fr/ {
    try_files $uri $uri/ @frrewrites;
}

And when I got the password reset link I had to manually remove the /en/ from the url and it works. Not perfect but at least I can reset passwords.

Not a solution but more of a temporary work around.

UPDATE 2

Not a fix - had to remove above code as it made all interior pages return a 404.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.