1

I am trying to make vhost, but it is kinda semi working. I am able to run the index.php and load home page, but when I try to go to any link I am getting:

Not Found

The requested URL /home was not found on this server.
Apache/2.4.7 (Ubuntu) Server at c2s.dev Port 80

(I am using yii2 framework, if that means something). I also can access the site using subdomain (I am getting Server not found). What is the proper configuration? I am using Linux Mint 17.1 with default LAMP settings. This is my c2s.conf:

<VirtualHost 127.0.1.1:80>
  DocumentRoot /var/www/c2c/www
  ServerName c2s.dev
  ServerAlias *.c2s.dev
</VirtualHost>

And in /etc/hosts I added this:

127.0.1.1   c2s.dev
127.0.1.1   *.c2s.dev
Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
Sasha
  • 123
  • 1
  • 5

1 Answers1

0

The official site of Yii explains how to configure vhost for apache. You can see the examples here

For apache basically the configuration is:

<Directory "path/to/basic/web">
    # use mod_rewrite for pretty URL support
    RewriteEngine on
    # If a directory or a file exists, use the request directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Otherwise forward the request to index.php
    RewriteRule . index.php

    # ...other settings...
</Directory>

For you case it could look like this:

<VirtualHost *:80>
    ServerName c2s.dev
    DocumentRoot /var/www/c2c/www
    <Directory /var/www/c2c/www>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

And the file .htaccess on the root web folder like this: Options +FollowSymLinks IndexIgnore /

<IfModule mod_rewrite.c>
    RewriteEngine on

    #RewriteBase /

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

    RewriteRule ^.*$ index.php
</IfModule>
Alejandro
  • 101
  • 2