Nginx url rewrite WordPress and ModPageSpeed conflict Nginx url rewrite WordPress and ModPageSpeed conflict wordpress wordpress

Nginx url rewrite WordPress and ModPageSpeed conflict


Solved by using another solution proposed on some plesk support page.So instead of using

if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; }

whe should use

if (!-e $request_filename) { set $test P; }if ($uri !~ ^/(pagespeed|plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon)) { set $test "${test}C"; }if ($test = PC) { rewrite ^/(.*)$ /index.php?$1; }


I have never used plesk, but normally I would just replace those if lines with try_files, like so:

try_files $uri /index.php?q=$uri&$args;

This sends all requests to existing files to those files and all other requests to index.php with the requested URL and possible other arguments as argument, like in your code.

As you only showed part of the config I can't judge whether the try_files line needs to be outside the location blocks or inside one.

As a general guideline, following the nginx documentation, I try to avoid if wherever possible (sometimes, admittedly, it isn't possible).