How could I permanently redirect dynamic url with querystrings?

Gena Makhomed gmm at csdoc.com
Sun Jun 20 16:39:20 MSD 2010


On 20.06.2010 14:06, WisdomFusion wrote:

>> - rewrite ^.*$ http://www2.example.com/thread-$tid-1-1.html permanent;
>> + rewrite ^ http://www2.example.com/thread-$tid-1-1.html? permanent;

>> - rewrite ^(.*) http://www2.example.com$1 permanent;
>> + rewrite ^ http://www2.example.com$request_uri? permanent;

> Thanks. ^^
>
> It works perfect. Thanks a lot.
>
> By the way, I always refers to configuration from
> http://wiki.nginx.org/NginxHttpRewriteModule, but it's so brief that
> some details like this problem I encountered are not included. Where
> could I find more detailed reference materials?

high quality English documentation can be located
at official nginx site: http://nginx.org/en/docs/

information about "question mark as the last character"
present at http://wiki.nginx.org/NginxHttpRewriteModule:

If in the line of replacement arguments are indicated, then the rest of 
the request arguments are appended to them. To avoid having them 
appended, place a question mark as the last character:

   rewrite  ^/users/(.*)$  /show?user=$1?  last;

'^' character is pcre regexp, it means 'start of string',
more detailed manual about Perl Compatible Regular Expressions
syntax is http://perldoc.perl.org/perlre.html
or http://www.pcre.org/pcre.txt

$request_uri - internal nginx variable,
it described at http://wiki.nginx.org/NginxHttpCoreModule

P.S.

quite often English documentation at http://wiki.nginx.org/
are more detailed than russian http://sysoev.ru/nginx/docs/
(wiki describes many undocumented nginx options and features)

but Russian documentation at http://sysoev.ru/nginx/docs/
always more accurate and correct than information at wiki,
because Russian documentation maintained in sync
with main development branch by creator of nginx.

it can be readed in english via Google Translate.

-- 
Best regards,
  Gena



More information about the nginx mailing list