Там не \n, а последовательность \r\n.
Ну и зачем тут preg_replace, если достаточно strtr или str_replace.
$string = strtr($string, ["\r" => "\\r", "\n" => "\\n"]);
location ~ \.php($|/) {
Так там еще и сам шаблон в location поправить \.php$ на \.php($|/)
location / { try_files $uri /index.php$uri;}location ~ \.php($|/) { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info;
Dram, а в php скрипте из какой переменной берётся адрес $_SERVER['REQUEST_URI'] или $_SERVER['PATH_INFO']?
Ну и в настройках nginx глянуть как задаётся fastcgi_param PATH_INFO.
RewriteCond %{THE_REQUEST} \? RewriteCond %{THE_REQUEST} !\= RewriteRule ^(.*)$ /$1? [R=301,L]
$content=preg_replace('#^(?>.*?\K<h2){6}#s','<p style="text-align: center;">'.$ads.'</p><h2',$content,1);
Мята,
RewriteCond %{HTTP_HOST} ^домен\.ru($|:) [NC]RewriteRule ^(.*)$ http://www.домен.ru/$1 [R=301,L]
Или
RewriteCond %{HTTP_HOST} ^(?!www\.)([^:]+) [NC]RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}$1 -f RewriteRule ^.+(/[^/]+\.txt)$ $1 [L]
RedirectMatch 301 ^/uslugi/$ https://domain.ltd/new-page/ RedirectMatch 301 ^/uslugi/type-1/$ https://domain.ltd/new-page/ RedirectMatch 301 ^/uslugi/type-2/$ https://domain.ltd/new-page/
RewriteEngine On RewriteRule ^uslugi/$ https://domain.ltd/new-page/ [R=301,L] RewriteRule ^uslugi/type-1/$ https://domain.ltd/new-page/ [R=301,L] RewriteRule ^uslugi/type-2/$ https://domain.ltd/new-page/ [R=301,L]
kminas,
RewriteCond %{HTTP_HOST} ^www\.ru\.new-site\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^(www\.)?old-site\.com$ [NC] RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^(.*)$ http://ru.new-site.com/$1 [R=301,L]