location = /admin/index.php {
if ($arg_route ~ "/mod2") {
rewrite ^ mod2 last;
}
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 60;
}
location = mod2 {
rewrite ^ /admin/index.php break;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 1000;
}
Мне необходимо написать так, что если метод не POST (GET, HEAD), то выдавать не 0.
map $request_method $cache_hit {
"~*post" 0;
default 1;
}
map $request_method $cache_hit {
POST 0;
default 1;
}
set $cache_hit 1;
# POST requests and urls with a query string should always go to PHP.
if ($request_method = POST) {
set $cache_hit 0;
}
if ($query_string != "") {
set $cache_hit 0;
}
# Don't cache uris containing the following segments.
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_hit 0;
}
# Don't use the cache for logged-in users or recent commenters.
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_hit 0;
}
map $query_string $check_query_string {
"" 0;
default 1;
}
map $request_uri $check_request_uri {
"~*(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)" 1;
default 0;
}
map $http_cookie $check_cookie {
"~*comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in" 1;
default 0;
}
map "$request_method:$check_query_string:$check_request_uri:$check_cookie" $cache_hit {
"~^POST" 0;
"~1" 0;
default 1;
}
RewriteRule ^main$ main.html [L]
/main
/main/
нужен шаблон ^main/$
RewriteRule ^main/$ main.html [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ https://site.ru/$1 [R=301,L]
RewriteCond %{ENV:HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?route=$1 [L,QSA]
map "$geoip_country_code,$http_user_agent" $deny {
default 0;
~^US.*Googlebot 0;
~^US 1;
~^CN 1;
}
server {
if ($deny) {
return 403;
}
ssl on;
Эта директива устарела в версии 1.15.0. Вместо неё следует использовать параметр ssl директивы listen.
server {
listen 443 ssl http2;
RewriteCond %{SERVER_NAME} ^(www|blog|project|xerox)\.* RewriteCond %{REQUEST_URI} ^/favicon.ico$ RewriteRule ^ %1/favicon.ico [L]
RewriteCond %{REQUEST_URI} ^/favicon.ico$
RewriteCond %{SERVER_NAME} ^(www|blog|project|xerox)\.*
RewriteRule ^ %1/favicon.ico [L]
RewriteCond %{SERVER_NAME} ^(www|blog|project|xerox)\.*
RewriteCond %{REQUEST_URI} =/favicon.ico
RewriteRule ^ %1/favicon.ico [L]
RewriteRule ^page/([0-9]+)/$ index.php?page=$1 [L,QSA]
RewriteRule ^cat/([0-9]+)/(.*)/([0-9]+)/$ cat.php?id=$1&name=$2&page=$3 [L,QSA]
RewriteRule ^cat/([0-9]+)/(.*)/$ cat.php?id=$1&name=$2 [L,QSA]
RewriteRule ^collections/$ collections.php [L,QSA]
RewriteRule ^collections/([0-9]+)/$ collections.php?page=$1 [L,QSA]
RewriteRule ^search/(.*)/([0-9]+)/$ search.php?q=$1&page=$2 [L,QSA]
RewriteRule ^search/(.*)/$ search.php?q=$1 [L,QSA]
rewrite ^/page/([0-9]+)/$ /index.php?page=$1 last;
rewrite ^/cat/([0-9]+)/(.*)/([0-9]+)/$ /cat.php?id=$1&name=$2&page=$3 last;
rewrite ^/cat/([0-9]+)/(.*)/$ /cat.php?id=$1&name=$2 last;
rewrite ^/collections/$ /collections.php last;
rewrite ^/collections/([0-9]+)/$ /collections.php?page=$1 last;
rewrite ^/search/(.*)/([0-9]+)/$ /search.php?q=$1&page=$2 last;
rewrite ^/search/(.*)/$ /search.php?q=$1 last;
DirectorySlash off
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule (.*) /$1.html [L]