location ~ /(wp-login|admin)\.php {
set $humantest 0;
if ($http_cookie !~* "humans=checktest") {
set $humantest 1;
}
if ($args ~* (callback|logout|lostpassword)) {
set $humantest 0;
}
if ($humantest = 1) {
add_header Content-Type text/html;
return 200 "<html><body><script>document.cookie='humans=checktest;path=/';location.reload();</script></body></html>";
}
error_page 404 = @fallback;
include fastcgi_params;
fastcgi_pass ...
}
location ~ \.php
server {
listen 80;
server_name xxx.ru;
root /var/www/html/vfm;
index index.php;
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass fastcgi_backend_71;
}
location ^~ /hite {
root /var/www/html;
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass fastcgi_backend_71;
}
}
}
rewrite ^/(?:(.*)/|)index\.(?:php|htm) /$1 permanent;
rewrite ^/(.*)\.(php|htm) /$1 permanent;
rewrite ^/(.*)/$ /$1 permanent;
rewrite ^/page/([^/]*)$ /page.php?param=$1;
rewrite ^/$ /index.php;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location / {
try_files $uri @extensionless-php;
}
location @extensionless-php {
try_files $uri.php $uri/index.php =404;
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
error_page 404 /error;
RewriteRule ^news/(sport)$ /pages/news.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteRule ^news/(sport)$ /pages/news.php?type=sport [L]
RewriteRule ^uslugi/new_usluga/$ /folder/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
[OR]
можно обойти проверку существования папки RewriteCond %{REQUEST_FILENAME} !-d
.RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/uslugi/ [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
DirectoryIndex
сделает свое дело и при запросе существующей папки /uslugi/new_usluga/ будет вызван /uslugi/new_usluga/index.php. Остальные запросы, как и прежде, обработает index.php в корне сайта. Нужно, чтобы захватывал многострочно. Флаг m стоит.
^ $
, а их нет в данной регулярке.s
совпадение будет и с переводами строк. 2. При написании редиректа с главной страницы rukartina.ru перенаправляет на несуществующую страницу https://rakovgallery.ru/index.php
В чем проблема?
RewriteRule ^(.*)$ index.php
, поэтому редиректы нужно добавлять в начало файла, чтобы они срабатывали раньше, чем другие правила.RewriteEngine On RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC] RewriteRule ^([^/]+) $1 [L] RewriteCond %{HTTP_HOST} ^www.rukartina\.ru$ [NC] RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^rukartina\.ru RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]
RewriteEngine On
RewriteCond %{THE_REQUEST} "! /robots\.txt"
RewriteCond %{HTTP_HOST} ^(www\.|)rukartina\.ru$ [NC]
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]
(?:.*?\K symbol ){N}
(?:.*?\K\.){3}
\K
https://regex101.com/r/A7aQ0I/2((?:.*?\.){2}.*?)\.
$1 (ЗАМЕНА)
Require expr "req_novary('CF-Connecting-IP') -ipmatch '1.2.3.0/24' "
Require expr "req_novary('CF-Connecting-IP') -ipmatch '7.7.7.7' "
RewriteEngine On
RewriteCond %{HTTP:CF-Connecting-IP} !^1\.2\.3
RewriteCond %{HTTP:CF-Connecting-IP} !=7.7.7.7
RewriteRule ^ - [R=403,L]
location /wp {
root /var/www/mysite;
try_files $uri /wp/index.php?args;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
}
}
## Begin - Joomla! core SEF Section. # RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] # # If the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script # and the request is for something within the component folder, # or for the site root, or for an extensionless URL, or the # requested URL ends with one of the listed extensions RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{SERVER_PORT} !^443$
должно стоять над RewriteRule .* https://
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP:Front-End-Https} !on