skip to Main Content

I have a Yii2 application working in a computer with Debian. Then I tried to run it in another computer with Windows 8 but it doesn’t work.

I copied the entire application folder to Apache’s htdocs folder but when I run it in a browser it shows:

404 Not Found

Apache access.log:

::1 - - [12/Jul/2018:09:03:40 -0300] "GET /donaciones-yii/backend/web/site/login HTTP/1.1" 404 235
::1 - - [12/Jul/2018:09:03:40 -0300] "GET /favicon.ico HTTP/1.1" 200 1150

This is the content of the file backend/web/index.php:

<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');

$config = yiihelpersArrayHelper::merge(
    require(__DIR__ . '/../../common/config/main.php'),
    require(__DIR__ . '/../../common/config/main-local.php'),
    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-local.php')
);

(new yiiwebApplication($config))->run();

@rob_006: I don’t have the backend/web/.htaccess file in Debian neither Windows computers:
enter image description here

4

Answers


  1. Chosen as BEST ANSWER

    I solved it disabling pretty URLs.


  2. As per rob006 comment, you should have been added .htaccess file to your web folder that contains the following:

    Options +FollowSymLinks
    IndexIgnore */*
    
    RewriteEngine on
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . index.php
    

    and pretty urls will work.

    Login or Signup to reply.
  3. when run yii in docker container, add to /web/.htaccess

    Options +FollowSymLinks
    IndexIgnore */*
    
    RewriteEngine on
    
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . index.php
    
    Login or Signup to reply.
  4. $ sudo nano /etc/apache2/sites-available/000-default.conf
    

    add

    <Directory "/var/www/">
                AllowOverride All
        </Directory>
    

    sava and exit

    service apache2 restart 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search