Stack Overflow на русском Asked on January 4, 2021
сайт находится на VPS, первый раз не правильно настроил сервер, а именно с виртуальными хостами не мог совладать, по этому сайт был залит в корень и прекрасно работал. Не много разобравшись, правильно сконфигурировал сервер, залил сайт и теперь открывается только главная страница, при переходе на другие страницы получаю 404.
Конфигурация апач:
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
ServerName parkaukcyjny.pl
ServerAlias www.parkaukcyjny.pl
DocumentRoot /var/www/parkaukcyjny.pl/public_html/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLEngine on
</VirtualHost>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.mydomain.ru
ServerAdmin [email protected]
ServerName parkaukcyjny.pl
ServerAlias www.parkaukcyjny.pl
DocumentRoot /var/www/parkaukcyjny.pl/public_html/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Расположение файлов Yii2, все файлы из папки web залиты в папку public_html, остальные файлы фреймворка находятся на уровень выше в папке parkaukcyjny.pl.
В папке parkaukcyjny.pl лежит файл .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ /public_html/$1 [L]
RewriteCond %{REQUEST_URI} !^/public_html/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /public_html/index.php
</IfModule>
В папке public_html лежит файл .htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
В настройка urlManager ничего не указано:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
Перезаливал файлы, менял .htaccess, ничего не помогает, надеюсь уже только на вас.
И так проблема оказалась очень просто решаема. В файле конфигурации Апач
/etc/apache2/apache2.conf
Нужно было поменять
AllowOverride none
На
AllowOverride All
Для конкретной папки у меня это было
<Directory /var/www>
Options Indexes Includes
AllowOverride none
Allow from all
</Directory>
Answered by Дмитрий Папава on January 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP