File and directory matching, where:
*-F and!-f to determine if a file exists
*-D and!-d to determine if a directory exists
*-E and!-e to determine if a file or directory exists
*-X and!-x to determine if the file is executable
Example: Determine whether the access to the picture exists, there is no jump to another domain name
Location ~* ^.+. (jpg|jpeg|gif|css|png|js|ico| thumb) { root /data/wwwroot/bbs.xxx.com; Expires 10d; if (-e $request _filename) { ^/data/attachment/forum/(. *) $ http://img.xxx.com/forum/$1 permanent; } }
There is a problem here:
Incorrect syntax for overriding rewrite in Nginx [Emerg] unknown directive "if ($host! ="
Nginx syntax detection is particularly strict, if and after the parentheses and variable equals the elements must have spaces, so the correct wording is:
if ' www.0xcafebaby.com ' ) { ^ (. *) $ http://www.0xcafebaby.com$1 Permanent; }
Use a ^ instead of a space to look clearer:
if^ (^ $host ^!=^'www.0xcafebaby.com'^) {
Anyway more dozen space is, so nginx in the Chinese configuration file interpretation can refer to: Nginx configuration file Chinese comments in detail if you want to know more Nginx rewrite configuration, can refer to: Nginx rewrite parameters Daquan
Nginx to determine that access to the file or directory does not exist rewrite