am trying to run location with same rule of rewrite
nginx rewrite
rewrite ^/([0-9]+)$ /post.php?id=$1 ;
not working with
location ~ ^/([0-9]+) {
try_files /s.php-$1.txt /s.php?page=$1 ;
root /home/XX/public_html;
types {}
default_type text/html;
}
it's working good if i add any word like ^/S([0-9]+)
but without S this rule damage all images and others urls
i had a years trying to fix it , with no hope
today , i found idea when see way of 404 with custom location
error_page 500 502 503 504 404 /custom.html;
location = /custom.html {
try_files /cachep/index.txt /index.php ;
root /home/xxx/public_html;
types {}
default_type text/html;
}
so what , if rewrite working good
we will use it with location with same way
rewrite ^/([0-9]+)$ /T$1 ;
location ~ /T([0-9]+) {
try_files /cachep/$1.html /post.php?id=$1 ;
root /home/xxx/public_html;
expires max;
types {}
default_type text/html;
}
i use
types {}
default_type text/html;
to make txt file viewing like html
i hope one day any one search for same problem Found it