Tricky Rewrite rules.

Hone developerhondev at gmail.com
Wed Nov 21 07:29:55 MSK 2007


I had this idea but it didn't work:

if (!-e /wp-content/cache/supercache/$http_host/$request_filename) {
rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html
break;
}


> Well that does work, if first the file exists. But before that I have to 
> check for the existence of the file with a if, but I cant have recursive 
> if's. Handling the string's and queries is not difficult, But Im having 
> problems after doing the if's for query's and cookies.
> 
> To be more specific:
> 
>     if (-f /wp-content/cache/supercache/mydomain.com/$1index.html ) {
>       rewrite ^(.*)$
> /wp-content/cache/supercache/mydomain.com/$1index.html last;
>     }
> 
>     if (!-e $request_filename) {
>       rewrite ^(.*)$  /index.php?q=$1  last;
>     }
> 
> Aparently sometimes does work, other gives weird 404's and 500's.







More information about the nginx mailing list