Question

Forgive me for such a frequent situation, I searched the Internet. I tried it, I didn't have anything goes. I can't configure routing in Yii. I would be grateful if anybody can help a beginner:

1) I have a finished project to Yii.

2) I have the cloud to digitalocean, installed the LAMP, in the/var/www/html uploaded project.

3) My /var/www/html/.htaccess

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

4) /var/www/protected/config/main.php

// uncomment the following to enable URLs in path-format
    'urlManager' => array(
        'urlFormat' => 'path',
        'rules' => array(
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
        ),
        //not show index.php
        'showScriptName' => false,
    ),

5) /var/www/html/protected/.htaccess

deny from all

6) Yii framework in /var/www/yii.

If you enter the URL of the project via a browser, enter /var/www/html/, /var/www/yii/does not see, is this normal? Tell me how to configure the correct routing? (without "/?r="). Folders 777, Files 666 rewrite_module (shared)

Était-ce utile?

La solution

Well I would suggest to change your .htaccess file from (http://www.yiiframework.com/wiki/427/htaccess-seo-friendly-url/)

RewriteEngine on
RewriteBase /
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)

# otherwise forward it to index.php
RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]

Now if you have not set virtual host and application is in some folder like /var/www/html/MySite. Then change RewriteBase in .htaccess to RewriteBase /MySite

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top