title: How to remove index,php from CI project url to make clean url in nginx Hostwinds server, when CI project is inside subdirectory?
body: <p>"I'm setting up an Nginx server on Hostwinds for CI project which is in a subdirectory. Where I want to make a clean URL by removing index.php. Initially, this project was running on Apache server and with the help of .htaccess file, I have made a clean URL by removing index.php. But .htaccess file not works on the Nginx server. So, tell me what codes should I use to remove index.php from URL in 'Hostwinds' Server.</p>
  
  <p>In subdirectory home page of projects opens but when you click on any of its links it will redirects you to 404 page.</p>
  
  <p>I have tried various solution which is available on the internet but none of them worked for me. I have used this code inside nginx.conf file.
  some of them:-</p>
  
  <p>1)  </p>
  
  <pre><code>location /category/subcategory {
      try_files $uri $uri/ /category/subcategory/index.php; 
      }
  </code></pre>
  
  <p>2)   </p>
  
  <pre><code>location /subfoldername/ {
      root /usr/share/nginx/www/subfoldername;
      try_files $uri $uri/ /index.php?$query_string;
      }
  </code></pre>
  
  <p>3)  </p>
  
  <pre><code>location /api/ {
      alias  /var/www/api/;
      try_files $uri $uri/ /api/index.php;
  
      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_index   index.php;
          fastcgi_pass    backend;
          include /etc/nginx/fastcgi_params;
          fastcgi_param   SCRIPT_FILENAME $request_filename;
      }
      }
  </code></pre>
  
  <p>4)  </p>
  
  <pre><code>location /nested {
      alias /var/www/nested/public;
      try_files $uri $uri/ /index.php$is_args$args;
      }
  
  
  
  ...http {...
  
  server {
      listen 443 ssl http2;
      #listen [::]:443 ssl http2 ipv6only=off;
      server_name example.com;
    location / {
      index  index.html index.htm index.php;
      try_files $uri $uri/ @backend;
  
    }
  
  
  
    location @backend {
      include proxy_params_common;
      # === MICRO CACHING ===
      # Comment the following line to disable 1 second micro-caching for dynamic 
    HTML content
      include proxy_params_dynamic;
    }
  
  
  
    # Enable browser cache for static content files (TTL is 1 hour)
    location ~* \.(?:json|xml|rss|atom)$ {
      include proxy_params_common;
      include proxy_params_static;
      expires 1h;
    }
  
    # Enable browser cache for CSS / JS (TTL is 30 days)
    location ~* \.(?:css|js)$ {
      include proxy_params_common;
      include proxy_params_static;
      expires 30d;
    }
  
    # Enable browser cache for images (TTL is 60 days)
    location ~* \.(?:ico|jpg|jpeg|gif|png|webp)$ {
      include proxy_params_common;
      include proxy_params_static;
      expires 60d;
    }
  
    # Enable browser cache for archives, documents &amp; media files (TTL is 60 days)
    location ~* \. 
   (?:3gp|7z|avi|bmp|bz2|csv|divx|doc|docx|eot|exe|flac|flv|gz|less|mid|midi|mka|mkv|mov|mp3|mp4|mpeg|mpg|odp|ods|odt|ogg|ogm|ogv|opus|pdf|ppt|pptx|rar|rtf|swf|tar|tbz|tgz|tiff|txz|wav|webm|wma|wmv|xls|xlsx|xz|zip)$ {
      set $CACHE_BYPASS_FOR_STATIC 1;
      include proxy_params_common;
      include proxy_params_static;
      expires 60d;
     }
  
    # Enable browser cache for fonts &amp; fix @font-face cross-domain restriction (TTL is 60 days)
     location ~* \.(eot|ttf|otf|woff|woff2|svg|svgz)$ {
       include proxy_params_common;
      include proxy_params_static;
      expires 60d;
      #add_header Access-Control-Allow-Origin *;
     }
  
     # Prevent logging of favicon and robot request errors
     location = /favicon.ico {
      include proxy_params_common;
      include proxy_params_static;
      expires 60d;
      log_not_found off;
     }
  
     location = /robots.txt  {
      include proxy_params_common;
      include proxy_params_static;
      expires 1d;
      log_not_found off;
    }
    # Deny access to files like .htaccess or .htpasswd
    location ~ /\.ht {
      deny all;
    }
  
  
  
  }
  </code></pre>
  
  <p>Initially  link:- www.example.com/index.php/search-result</p>
  
  <p>resulted in link:- www.example.com/search-result</p>