. 1 min read
In this post, I will show you how we can Ignore or exclude specific files or folder from NGINX configuration.
Before we start updating the configuration file I hope you have good knowledge of the NGINX server because if something goes wrong in the config file your site goes down, and to update configuration file you need complete access of server.
Step 1. Login to the server via terminal or putty.
Step 2. Go to cd /etc/nginx location
and open you site configuration file nano
xyz.mysite.com
.
Step 3. Open file is open for the edit you can ready to change the setting. Now if you only want to allow specific files to ignore then you can change setting like this.
location / { rewrite ^/((?!manifest.json|pwabuildersw.js).*)$ /index.php?slug=$1 last; }
In my case, I want to ignore the manifest.json file and pwabuildersw.js file so I can update my configuration as shown in the above code.
Step 4. If you want to ignore a specific folder you can do like this.
location /assets { # Nothing here }
In my case, I want to ignore assets folder.
Step 5. If you want to ignore both folder and specific file then you can do like this as shown in the below code.
server { listen 80; listen [::]:80; root /var/www/html/test/sample; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name MY_SERVER_ADDRESS; location /assets { # Nothing here } location / { rewrite ^/((?!manifest.json|pwabuildersw.js).*)$ /index.php?slug=$1 last; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.2-fpm.sock; } location ~ /\.ht { deny all; } }
Step 6. Save your file by pressing ctrl+o
and exit ctrl+x
.
Step 7. Reload your NGINX configuration sudo systemctl reload nginx
.
That’s it now you can check your site. I hope you understand how to Ignore specific files and folders in NGINX server.
Implement Google Mobile Ads in your React Native application to allows you to monetize your app with AdMob.
Learn how to deploy React and Node.Js application using CI/CD pipeline with Github Actions.
DevOps is a set of practices, tools, and a cultural philosophy that automate and integrate the processes between software development and IT teams. It emphasizes team empowerment, cross-team communication and collaboration, and technology automation.
Learn different between find(), filter() and map() in javascript with example and other array methods in javascript.
MongoDB is an open-source document-oriented database that is designed to store a large scale of data and also allows you to work with that data very efficiently. It is categorized under the NoSQL (Not only SQL) database because the storage and retrieval o