Answer the question
In order to leave comments, you need to log in
How to set up Yii2 for shared hosting?
Hello!
I'm trying to upload a ready site on Yii2 to virtual hosting.
Everything works fine on the locale, but from the hosting it gives out the page "Apache 2 Test Page powered
by CentOS
" +Indexes - does not help!
3. There is an entry in the error
log. I do not have access to the httpd.conf config.
So far, returned .htaccess in root to this form:Directory index forbidden by Options directive
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule ^fonts/(.*)$ web/fonts/$1 [L]
RewriteRule ^sitemap.xml web/sitemap.xml [L]
RewriteRule ^robots.txt web/robots.txt [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
Answer the question
In order to leave comments, you need to log in
Good evening.
If there were no index page, then most likely you would get a 403 error or yii2 would fail.
The problem, I think, is in the .htaccess and urlManager settings.
Try to do the following:
1) In the root of the project, put .htaccess with the following content
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ web/$1 [L]
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
'request' => [
'baseUrl' => '/name_folder', // перед именем должен быть слеш
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question