I was attempting to learn rewrites, by making something like this:

^/blog/install/(.*)$ --> /blog/install/index.php?_p=$1

However these rewrites simply kept failing, and it was difficult to investigate, so I looked and found rewrite_log on as an appropriate feature to help me. My error_log within my server block is set to notice level as per the NGINX guide as well, however wherever I place rewrite_log on and reload it will never log anything relating to rewrites, only nginx/php errors!

I tried to even set error_log to debug the only relevant information it would give me is the following line:

2015/12/14 13:46:26 [debug] 17458#0: *4494 http copy filter: 0 "/blog/install/index.php?_p="
2015/12/14 13:46:26 [debug] 17458#0: *4494 http finalize request: 0, "/blog/install/index.php?_p=" a:1, c:1

However nothing surrounding it (involving lines talking about SSL and HTTP filtering) mentions what exactly goes after _p= or all.

Some tests I've used for rewriting, I've tried many combinations of:

location /blog/install {
        try_files $uri $uri/ @install;

location @install {
        fastcgi_pass unix:/var/run/php5-fpm-site_mainsite.sock;
        fastcgi_param SCRIPT_FILENAME $document_root/blog/install/index.php;
        fastcgi_param QUERY_STRING    _p=$uri&$args;
        include fastcgi_params;

Or something like...

location /blog/install {
        rewrite ^/blog/install/(.*)$ /blog/install/index.php?_p=$1? last;

And all sorts related, however the best I can get to is a CSS-less page (I'm guessing it is rewriting non-PHP files too.. ) or a next button that does not go to anywhere (it's sending /nextpage/ to who knows, the void) and I cannot debug any of this! Any clue?

Things I've checked..

  • /var/log/nginx/errors.log mentions only nginx reloading when I use reload for its service

  • nginx -V shows --with-debug, if that matters shrug

My current NGINX config for this is:

    error_log  /home/site_mainsite/log/errorslog.log notice;
    rewrite_log     on;

And I'm sure it is doing rewrites, since only /blog/install will allow arbitrary paths after it of which do not exist, whereas /blog/nonexistentblabla will give me a 404, yet, no rewrite logs..

  • Derp, It looks like I was just never matching anything and that was why. I am not sure if it would talk much if I used try_files, but with some new regex it is logging things now. Strange. – tiger Dec 14 '15 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.