Problem with return 302 redirection, with Nginx 1.3.11 + Drupal 7
Francis Daly
francis at daoine.org
Wed Jan 23 12:03:36 UTC 2013
On Wed, Jan 23, 2013 at 11:46:23AM +0000, Mark Alan wrote:
Hi there,
> location ~* ^/(\?q=)?(?:user|admin|contact$) {
> return 302 https://$host$request_uri;
> }
That probably won't match the request that you want it to match.
> What should I do to get http://example.com/?q=user redirected to
> https://example.com/user or, if that is not possible, to
> https://example.com/?q=user ?
The request http://example.com/?q=user has location = /, and $query_string
= q=user, and $arg_q = user.
So you should use some combination of those variables within
location = / {}
to do the redirection.
Use $arg_q if you don't care about any other parts of the query string. If
you have many things to compare, creating a "map" is probably worthwhile.
And you'll also want to consider what to do in that location if $arg_q
is not one that you want to redirect -- possibly just letting it fall
through to the "index" value will do.
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list