How to do URL Friendly

1

I'm using Framework Yii and need to create URLs friendly.

URL Example: http://meudominio.com/meuControle/minhaView
That is Equivalent to: http://meudominio.com/index.php?r=meuControle/minhaView

No config/main.php enabled:

'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>',
    ),
),

But when I try to access some page using the Friendly URL, I have the following return:

  

404 Not Found

     

nginx / 1.4.6 (Ubuntu)

How do I resolve this?

    
asked by anonymous 26.11.2014 / 16:15

1 answer

2

Having made the necessary changes to config/main.php , you will need to change the settings on the Nginx server.

In the /etc/nginx/conf.d/default.conf file or in your server's file in the /etc/nginx/sites-available/ folder, add:

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$args;
}

#Bloqueia o acesso direto às pastas do Yii
location ~ ^/(app|framework|themes/\w+/views){
    deny all;
}

#Bloqueia o acesso direto aos recursos estáticos
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    try_files $uri =404;
}

And finally, restart the service.

# service nginx restart

For more information, English documentation .

    
26.11.2014 / 17:37