Мне нужно разместить сайт внутри существующего проекта. 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
Расположение Nginx с псевдонимом перенаправить на корень ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1753762796
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;
Подробнее здесь: [url]https://stackoverflow.com/questions/79718099/nginx-location-with-alias-redirect-to-root[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия