rewrite ^/test$ /test.php;
location / {
try_files $uri @php;
}
location @php {
try_files $uri.php =404;
fastcgi_pass ... ;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
php.mysite.ru/phpmyadmin
было php.mysite.ru/
нужно исправить root путь.server {
listen 80;
listen [::]:80;
root /var/www/html/phpmyadmin;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name php.mysite.ru
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
}
https://site.ru
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name site.ru;
ssl_certificate ... ;
ssl_certificate_key ... ;
}
Если у совпавшего префиксного location’а максимальной длины указан модификатор “^~”, то регулярные выражения не проверяются.
location /site2/
добавить ^~
location /site1 {
добавить location ~* \.php$
location /site1 {
root /var/www/site1;
location ~* \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; # подключаем сокет php-fpm
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ^~ /site2/ {
proxy_pass https://site2/;
}
server_name domain.ru;
location /api/ {
root /var/www/site.ru;
rewrite ^ /index.php break;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
server {
client_max_body_size 32M;
location /faq/upload {
client_max_body_size 400M;
try_files $uri @admin_upload;
}
location @admin_upload {
rewrite ^ /index.php break;
fastcgi_pass ... ;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass ... ;
include fastcgi_params;
}
server
{
...
location ~* ^/build/.*\.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
log_not_found off;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
log_not_found off;
}
}
map $arg_arg1 $conf {
default "conf.js";
"4982948394" "conf2.js";
}
server {
location = /conf.js {
alias /config/$conf;
}
map $request_uri $index {
default "0";
"~/bitrix/admin/" "0";
"~/auth/" "0";
"~^(.*)index\.(?:php|html)(\?.+)?" "$1$2";
"~^/\?old=\d+&(.+)" "/?$1";
"~^/\?old=\d+" "/";
}
if ($index != 0) {
return 301 $index;
}
server {
listen 80;
listen [::]:80;
server_name api.mysite.ru;
location / {
proxy_pass http://mysite.ru/api/;
}
}
server {
listen 80;
listen [::]:80;
root /var/www/mysite/public;
index index.php index.html;
server_name api.mysite.ru;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param REQUEST_URI /api$request_uri;
}
}