title: Ngnix Location Alias directive always returning 404
body: <p>I want when someone access <a href="http://abhinav.epaper.lc/media" rel="nofollow noreferrer">http://abhinav.epaper.lc/media</a> then he should get contents from /home/ankurgupta/websites/lc/uploads/abhinav.epaper.lc/</p>
  
  <p>But <a href="http://abhinav.epaper.lc/media/a.jpg" rel="nofollow noreferrer">http://abhinav.epaper.lc/media/a.jpg</a> always returns 404 error.
  But a.jpg is present in /home/ankurgupta/websites/lc/uploads/abhinav.epaper.lc/a.jpg</p>
  
  <p>Here is the configuration:</p>
  
  <pre><code>server {
  
  
      listen 80;
      listen [::]:80;
      server_name abhinav.epaper.lc;
      root /home/ankurgupta/websites/lc;  
      index index.php;
      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }   
      location /media {
          alias /home/ankurgupta/websites/lc/uploads/abhinav.epaper.lc;
      }   
      location ~ \.php$ {
          try_files $uri =404;
          include nginxconfig.io/php_fastcgi.conf;
      }
      include nginxconfig.io/general.conf;
  }
  </code></pre>
  
  <p>nginxconfig.io/general.conf;</p>
  
  <pre><code># security headers
  add_header X-Frame-Options "SAMEORIGIN" always;
  add_header X-XSS-Protection "1; mode=block" always;
  add_header X-Content-Type-Options "nosniff" always;
  add_header Referrer-Policy "no-referrer-when-downgrade" always;
  add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
  
   . files
  location ~ /\. {
      deny all;
  }
  
  # assets, media
  location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
      expires 7d;
      access_log off;
  }
  
  # svg, fonts
  location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
      add_header Access-Control-Allow-Origin "*";
      expires 7d;
      access_log off;
  }
  
  # gzip
  gzip on;
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
  </code></pre>
  
  <p>nginxconfig.io/php_fastcgi.conf;</p>
  
  <pre><code># default fastcgi_params
  include fastcgi_params;
  
  # fastcgi settings
  fastcgi_pass                    unix:/var/run/php/php7.2-fpm.sock;
  fastcgi_index                   index.php;
  fastcgi_split_path_info         ^(.+\.php)(/.+)$;
  
  fastcgi_param DOCUMENT_ROOT     $realpath_root;
  fastcgi_param SCRIPT_FILENAME   $realpath_root$fastcgi_script_name;
  fastcgi_param PHP_ADMIN_VALUE   "open_basedir=$base/:/usr/lib/php/:/tmp/";
  
  fastcgi_intercept_errors        off;
  fastcgi_buffer_size             128k;
  fastcgi_buffers                 256 16k;
  fastcgi_busy_buffers_size       256k;
  fastcgi_temp_file_write_size    256k;
  </code></pre>