Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have redirection cycle. Please help me as I don't know what to do with this.

And when I add this code

rewrite ^/(.*)$ /index.php?r=$1 ;

to the php-related location-block I will get an 500 error

My nginx configuration file:

server {
    listen 80;
    server_name xxxx;
    root /home/xx/public_html/yy;

    set $yii_bootstrap "index.php";

    location / {
        #try_files $uri $uri/ /index.php?$args;
        rewrite ^/(.*)$ /index.php?r=$1 ;
        #try_files $uri $uri/ /index.php$request_uri;
    }

    location  ~* \.(js|css|png|jpg|jpeg|gif|ico|ttf|woff|swf|ico)$ {           
        root /home/iorder/public_html/app;
        access_log off;
        log_not_found off;
        expires 3d;
        add_header Pragma public;
        add_header Cache-Control "public, max-age=259200";
        break;
    }

    location /munin{
        alias /var/cache/munin/www;
        auth_basic "Restricted";
        auth_basic_user_file /var/cache/munin/www/.htpasswd;
                          }
        access_log /var/log/nginx/access.log ;
        error_log /var/log/nginx/error.log  ;


        error_page 404 /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
        location ~ \.php$ {
            root /xx/iorder/public_html/yy;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;           
            #rewrite ^/(.*)$ /index.php?r=$1;             
            fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
            include /etc/nginx/conf/fastcgi_params;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

            #Yii Setting    
        #let yii catch the calls to unexising PHP files
            set $fsn /$yii_bootstrap;
        if (-f $document_root$fastcgi_script_name){
                set $fsn $fastcgi_script_name;
        }

            fastcgi_param SCRIPT_FILENAME $document_root$fsn;
            #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_script_name;
        }

        # deny access to .htaccess files, if Apache's document root concurs with nginx's one
        #
        location ~ /\.ht {
            deny all;
        }
     location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass unix:/var/run/php5-fpm.sock;
                       #fastcgi_param HTTPS $fastcgi_https; # <-- add this line
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/conf/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
    }
share|improve this question
    
With redirection cycle, do you mean redirection loop? –  pkhamre Jan 29 at 13:06
    
Why do you have all these rewrites? What happened to your try_files? Did you download this configuration somewhere? It is so messy I expect you should delete it and start over. –  Michael Hampton Jan 29 at 15:51
    
yes redirection loop i have'nt dowload it just try it alot of time by adding # to the configuration to got it work. when i uncommnet try_files it will fall to the infinit loop –  esxzawq Jan 29 at 19:03
    
should I do something with Yii configuration ? I have add the url manager to the protected/config/main.php. when I add break at the end of the rewrite int the php block it will give me "Access Denied" –  esxzawq Jan 29 at 19:09

1 Answer 1

I found The Answer :

The Problem was from Yii configuration

1) chmod 777 protected/runtime

2) mkdir asset # must be writable

3) uncomment the "defined('YII_DEBUG') or define('YII_DEBUG',true)"

that's all

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.