Question

I can't configure routing project in Yii is 3 days, all tried to help ... I have:

/var/www/ - project

/var/www/yii - yii framework

./htaccess

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is http://localhost/begin/, use /begin/

RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

index.php finds.

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

'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName' => false,
            'rules'=>array(
              '/'=>'/view',
              '//'=>'/',
              '/'=>'/',
            ),
    ),

When I enter for example 107.170.91.28/site/contact then displays an error 404. URL of server 107.170.91.28 On the local server. all works. If I enter this URL 107.170.91.28/index.php/site/contact or 107.170.91.28/index.php?r=site/contact - it works. Ask for help, because I tried all methods set.

Was it helpful?

Solution

If this is happening only on server it is either because you have configured Apache to ignore .htaccess directives on your server, or because you do not have Rewrite module loaded/installed

Either you can configure the apache conf to turn on by changing in /etc/apache2/apache2.conf (location may be different depending on OS , you can of course turn it only for application directory only as well

<Directory>
...
        AllowOverride None
....
</Directory>

to

<Directory>
...
        AllowOverride All
....
</Directory>

for enabling rewrite module you can do ( may vary depending on OS)

a2enmod rewrite

Restart apache2 after

/etc/init.d/apache2 restart

or

service apache2 restart
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top