title: nginx & laravel: rewrite or internal redirection cycle while internally redirecting to "/index.php"
body: <p>I am trying to upload my laravel app to my Digital Ocean droplet.</p>
  
  <p>I followed this <a href="https://asked.io/how-to-install-php-7-x--nginx-1-9-x---laravel-5-x" rel="nofollow noreferrer">tutorial</a> and now I am getting 500 server error.</p>
  
  <p>here is my nginx error.log:</p>
  
  <pre><code>2016/11/22 02:21:30 [error] 7733#7733: *1 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 198.7.58.98, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:25:05 [error] 7733#7733: *2 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 52.71.155.178, server: antique.samiemad.me, request: "GET /robots.txt HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:25:05 [error] 7733#7733: *3 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 52.71.155.178, server: antique.samiemad.me, request: "GET /info.php HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:30:53 [error] 7733#7733: *4 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 198.7.58.98, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:32:30 [error] 7733#7733: *5 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 52.71.155.178, server: antique.samiemad.me, request: "GET /info.php HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:35:52 [error] 7733#7733: *13 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 188.227.78.184, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:35:52 [error] 7733#7733: *14 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 188.227.78.184, server: antique.samiemad.me, request: "GET /favicon.ico HTTP/1.1", host: "antique.samiemad.me", referrer: "http://antique.samiemad.me/"
  2016/11/22 02:44:56 [error] 7733#7733: *15 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 198.7.58.98, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 02:57:59 [error] 7733#7733: *17 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 198.7.58.98, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  2016/11/22 03:02:30 [error] 7733#7733: *18 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 198.7.58.98, server: antique.samiemad.me, request: "GET / HTTP/1.1", host: "antique.samiemad.me"
  </code></pre>
  
  <p>I searched around for this error and I think there must be something wrong with my 'sites-available' files. I tried to play around with some values there but I couldn't get it to work yet.</p>
  
  <p>here are the current contents of my 'sites-available/antique.samiemad.me':</p>
  
  <pre><code>server {
      listen 80 ;
      listen [::]:80 ;
  
      root /var/www/antique.samiemad.me/public;
      index index.php index.html index.htm;
  
      server_name antique.samiemad.me;
      charset   utf-8;
  
      gzip on;
      gzip_vary on;
      gzip_disable "msie6";
      gzip_comp_level 6;
      gzip_min_length 1100;
      gzip_buffers 16 8k;
      gzip_proxied any;
      gzip_types
          text/plain
          text/css
          text/js
          text/xml
          text/javascript
          application/javascript
          application/x-javascript
          application/json
          application/xml
          application/xml+rss;
  
      location / {
          try_files \$uri \$uri/ /index.php?\$query_string;
      }
  
      location ~ \.php\$ {
          try_files \$uri /index.php =404; # tried to comment-out this line.. no luck :(
          fastcgi_split_path_info ^(.+\.php)(/.+)\$;
          fastcgi_pass unix:/run/php/php7.0-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
          include fastcgi_params;
      }
  
      location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
      }
  
      location ~* \.(?:css|js)\$ {
        expires 7d;
        access_log off;
        add_header Cache-Control "public";
      }
  
      location ~ /\.ht {
          deny  all;
      }
  
  }
  </code></pre>
  
  <p>I think maybe the problem is in one of the try_files commands?
  I tried to comment-out the line pointed out in the code but I still have the same error. So it must be something else causing this.</p>