Расположение Nginx с псевдонимом перенаправить на кореньPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Расположение Nginx с псевдонимом перенаправить на корень

Сообщение Anonymous »

Мне нужно разместить сайт внутри существующего проекта. site.com - это основной сайт, site.com/site2/ Это второе. site.com/site2/qwe он перенаправляет обратно на/index.php [fail]. Мне нужно/site2/web/index.php

Структура проекта:
/
/site2/
/site2/web/
/site2/web/index.php
/index.php
< /code>
nginx site conf < /p>
server {
root /var/www/site;
index index.php index.html index.htm;
...

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}

location /site2/ {
alias /var/www/site/site2/web/;

add_header X-Location-Visited true always;

try_files $uri $uri/ /index.php$is_args$args;
# I'd tried without any result
# try_files $uri $uri/ /site2/index.php$is_args$args;
# try_files $uri $uri/ /site2/web/index.php$is_args$args;

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
}

snippets/fastcgi-php.conf
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;


Подробнее здесь: https://stackoverflow.com/questions/797 ... ct-to-root
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»