Z
Z
zagamay_ru2015-12-28 16:52:43
Yii
zagamay_ru, 2015-12-28 16:52:43

How to set up htaccess, yii2?

Good afternoon!
Faced the problem of writing .htaccess for the project.
The project was made on local PHP 5.6 Apache 2.4
.htaccess is registered in the root of the project:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/     [L]
    RewriteRule (.*) public/$1 [L]
</IfModule>

All requests are redirected to the public folder, it also has .htaccess with the following content:
AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

And everything works fine on the local host, at the request site.ru/ru/about opens the page.
After I rolled it up to virtual hosting (PHP 5.6), everything broke down ..
At the request of site.ru/ru/about, it says No input file specified.
If you type site.ru/public/index.php/ru/about then it works correctly, tell me how to register correctly or what configurations should I look at?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zagamay_ru, 2015-12-28
@zagamay_ru

Resolved the issue.

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

A
Alexander N++, 2015-12-28
@sanchezzzhak

it is better to do as it is written in the documentation for this purpose it exists. ;)
https://github.com/yiisoft/yii2/blob/master/docs/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question