grep -oP '^[a-z]+(-[a-z]+)*'
grep -oP '^.+?(?=-\d|$)'
sed 's/-[0-9].*//'
В итоге перелинковка идет на https://newsite.ru/pesok/kvarceviy-pesok/, то есть добавляет в конец лишнее
Redirect 301 / https://newsite.ru/
оно и срабатывает.Redirect 301 /pesok/kvarceviy-pesok/ https://newsite.ru/pesok/
Redirect 301 / https://newsite.ru/
RedirectMatch 301 ^/$ https://newsite.ru/
RedirectMatch 301 ^/pesok/kvarceviy-pesok/$ https://newsite.ru/pesok/
PJSIP/(\d+)\S+ Up ([\d:]+).+?<(\d+)>
$str = '
Channel: Exten: CLCID: ========================================================================================== Channel: PJSIP/739-00009cf3/Dial Up 00:01:15 Exten: s CLCID: "CID:9622088888" <79379853222>
Channel: PJSIP/814-00009cf5/Dial Up 00:00:25 Exten: s CLCID: "CID:9622088888" <89119120799>
Channel: PJSIP/BEELINE_9622088888-00009cf4/AppDial Up 00:01:13 Exten: CLCID: "" <9622088888>
Channel: PJSIP/BEELINE_9622088888-00009cf6/AppDial Up 00:00:25 Exten: CLCID: "" <9622088888>
Objects found: 4
';
preg_match_all('~PJSIP/(\d+)\S+ Up ([\d:]+).+?<\K\d+~s', $str, $m, PREG_SET_ORDER);
print_r($m);
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
server {
listen 80;
listen [::]:80;
root /var/www/example_com;
index index.html index.php;
server_name example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Регулярные выражения задаются либо с модификатором “~*” (для поиска совпадения без учёта регистра символов), либо с модификатором “~” (с учётом регистра).
(?<name>...)
set $test $1;
location ~ ^/(?<test>test-a-[0-9]|test-b-[0-9]) {
proxy_pass http://$test;
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;