UNA nginx rewrite rules
2
1
location / {
    index index.html index.htm index.php;

    rewrite "^/path-to-una/page/(.*)$" /path-to-una/page.php?i=$1 last;
    rewrite "^/path-to-una/m/(.*)$" /path-to-una/modules/index.php?r=$1 last;
    rewrite "^/path-to-una/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)" /path-to-una/storage.php?o=$1&f=$2 last;
}

 

 

  • Rewrites not working.

    This is the server block in use.  Identifying info removed of course.

    server {
    listen 80;
    server_name xxxx.com www.xxxx.com;

    root /home/xxxx/public_html;
    index index.html index.htm index.php;

    access_log /var/log/virtualmin/xxxx_access_log;
    error_log /var/log/virtualmin/xxxx_error_log;

    # UNA Rewrites
    location / {
    index index.html index.htm index.php;

    rewrite "^/home/xxxx/public_html/page/(.*)$" /home/xxxx/public_html/page.php?i=$1 last;
    rewrite "^/home/xxxx/public_html/m/(.*)$" /home/xxxx/public_html/modules/index.php?r=$1 last;
    rewrite "^/home/xxxx/public_html/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)" /home/xxxx/public_html/storage.php?o=$1&f=$2 last;
    }

    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param

    ... see more CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME /home/xxxx/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /home/xxxx/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param HTTPS $https;
    location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/php-nginx/149481989221392.sock/socket;
    }

    }

    • This line is incorrect:

      rewrite "^/home/xxxx/public_html/page/(.*)$" /home/xxxx/public_html/page.php?i=$1 last;

      it should be the path after the document root, like this:

      rewrite "^/page/(.*)$" /page.php?i=$1 last;