Blog

How To Enable mod_rewrite In Nginx

In this tutorial, we are learning how to rewrite module in nginx and centOs machine. We are going to see how to do it for the mail directory and also for the sub-directory of the project.

Let’s see it

Nginx Mod_Rewrite URL Example

I am assuming you have CentOS machine and Nginx is installed on it. There are following steps will follow to implement url rewrite rules –

Step 1: I am assuming you’re using the default.conf file.We will open this file which is stored in /etc/nginx/conf.d/ folder –

Step 2: Search the below code into the virtual host file(default.conf).

We will make following changes into the above line and save the file –

Step 3: We will reload Nginx server service using below command –

sudo service nginx reload

How To Enable Mod_Rewrite for Subfolder

Normally, web hosting provider install WordPress site into the sub folder(sub_folder_name) then , We need to change location block as like below –

from –

replace To –

 

You need to restart nginx service or server. sudo service nginx reload

 

Thank you so much. Hope this was helpful for you.

Happy Learning !!

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

🚀 Let’s Connect on LinkedIn! 🚀

Want to level up your skills and knowledge? 🚀
Follow us on LinkedIn to get:
✅ Expert insights on business growth
✅ Daily tips to sharpen your skills
✅ Exclusive updates from The Coach SMB

Let's grow together!