A
A
AwFuL9992018-03-16 15:13:10
Yii
AwFuL999, 2018-03-16 15:13:10

Yii2 - after setting up the cnc, css and js files fly off. What could be the reason?

I decided to set up the CNC on yii2 (openserver), I found the instruction:
1. Placed .htaccess at the root:

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 (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

2. Placed .htacces in the web folder
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

3. Uncommented the lines in the web.php file:
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],

and added After adding baseUrl, all styles and scripts are disabled for me and the console issues: GET site.ru/css/site.css net::ERR_ABORTED - who faced this problem?
'baseUrl' => '',

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
Lander, 2018-03-16
@usdglander

First, set up the virtual host to look in the web folder. Now, apparently, it looks at you one level higher, into the application and framework directory.

A
Anton fon Faust, 2018-03-16
@bubandos

and in what folder is your style.css file on the server?

A
AwFuL999, 2018-03-16
@AwFuL999

Manual redirection through "Domains" works in openserver (hid web and also commented out 'baseUrl' => '').
The files are by default: site.ru- >web->css->site.css like a working method.

M
Maxim Timofeev, 2018-03-16
@webinar

You are building some kind of hell. Your domain should look at the web and not two levels above, then the first htaccess is not needed at all and everything will work like clockwork.
I tried at first (foolishly and inexperienced) the same approach as you. Difficulties are just beginning, and security is a big question. Just point the server to the web folder and that's it.
If there are problems with setting up the server, then just do it differently:
everything from the web folder to the root, and the entire framework to another. It remains only to correct the paths in index.php there are 6 lines.
Watch the video: https://youtu.be/hg5t5F3HdM4?list=PLOm4dl-NavgyBnt...
This is a structure for sharedhosting and when there is no other way. But it's probably easier and better to just send the domain to the web.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question