N
N
NewOpener2019-10-05 11:06:25
Yii
NewOpener, 2019-10-05 11:06:25

How to properly form cnc in yii2?

Hello. I started to learn yii2 and ran into difficulties in terms of forming cnc. I looked through many sources, including offguide, but I did not find the answer.
Tools used: php7, apache 2.4, yii2, composer. The server is localhost. Path to the application folder: С:/localhost/yii2project/.
What I tried to do:
apache settings

DocumentRoot "c:/localhost/yii2project/web"
<Directory "c:/localhost/yii2project/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

.httaccess at root (c:/localhost/yii2project)
RewriteEngine on
RewriteRule ^(.+)?$ /web/$1

.httaccess to web (c:/localhost/yii2project/web)
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

urlManager settings
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
    '<action:(about|contact|login|)>' => '/site/<action>',
                '<controller>/<action>' => '<controller>/<action>',
                
            ],
        ],

I tried many options, but none of them worked. Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NewOpener, 2019-10-05
@NewOpener

By the way, thanks to everyone who helped. Solved the problem as follows:
1) Apache settings (httpd.conf):

DocumentRoot "c:/localhost/yii2project/web"
<Directory "c:/localhost/yii2project/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

In the same file, uncomment the line #LoadModule rewrite_module modules/mod_rewrite.so
2) In this case, you don't need to create any special .htaccess anywhere. Leave the .htaccess file as is in the web folder.
3) Find the web.php file (in my case it is C:\localhost\yii2project\config), open it, uncomment the urlManager and add the following lines to it:
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            '' => '/site/index',
            '<action:(about|contact|login|)>' => '/site/<action>',
            '<controller>/<action>' => '<controller>/<action>',
                
            ],
        ],

As a result, CNC was launched on localhoste for the basic pages of the framework (index, about, contact, login), as well as for the pages I have already created

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question