A
A
agent11562016-09-14 22:48:56
Yii
agent1156, 2016-09-14 22:48:56

How to check the address bar?

I work in yii2 The main page has two addresses www.site.ru and www.site.ru/web/ the second happens when you go to the main home();
Because of this, there are problems with links. How to check address bar on /web/ ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skobkin, 2016-09-14
@skobkin

Make the server redirect/rewrite the address from /web/ to the root and don't have this problem.

D
Dmitry, 2016-09-14
@slo_nik

Good evening.
First .htaccess at the root

<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>

Second in the web directory
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#RewriteCond %{REQUEST_URI} ^/web/*
RewriteRule . index.php

This is if the site is at the root of the server.
If in a subdirectory, then in config/web.php add to the components section
'request' => [
            'baseUrl' => '/name_folder'
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question