Opened 3 years ago

Last modified 2 years ago

#2199 new enhancement

Online documentation: converting rewrite rules typo

Reported by: bwakkie@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.18.x
Keywords: RewriteRule Cc:
uname -a: Linux ... 5.8.0-53-generic #60-Ubuntu SMP Thu May 6 07:46:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-HdenXw/nginx-1.18.0=. -fstack-protector-strong -Wfor
mat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,
now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-pa
th=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/ --modules-path=/usr/lib/nginx/modules --
http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/
nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --
with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module -
-with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gun
zip_module --with-http_gzip_static_module --with-http_sub_module


is a typo in the converted rewrite rules:

Another example. Instead of the “upside-down” logic “all that is not and is not”:

    RewriteCond  %{HTTP_HOST}  !
    RewriteCond  %{HTTP_HOST}  !
    RewriteRule  (.*)$1

one should simply define,, and “everything else”:

    server {
        listen       80;

    server {
        listen       80 default_server;
        server_name  _;
        return       301$request_uri;

The last above bit ...

 return       301$request_uri;

... should be ...

 return       301$request_uri;

... as that is what is requested in the apache rewrite rule ...

    RewriteRule  (.*)$1

Same applies to the old version part...

On versions prior to 0.9.1, redirects can be made with:

        rewrite      ^$request_uri?;

... should be ...

        rewrite      ^$request_uri?;

OR change the Apache rewrite rule into:

    RewriteRule  (.*)$1

Change History (1)

comment:1 by maxim, 2 years ago

Milestone: nginx-1.21

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.