Question

How to insert a code before before location / block?

Posted April 7, 2021 292 views
NginxWordPress

Hi everyone, I am very new to nginx environment. I have installed WP CMS on my nginx server. Secondly, i am trying to hide the platform from cms detection so the wordpress hiding plugin wants me to manually rewrite the nginx.conf files and insert a rewrite code before the location / block of the configuration file.

Now usually the nginx.cinf files is location at /etc/nginx/sites-available/
however, in my case it under at /www/server/nginx/conf .

But the problem is there are two files of the configuration 1. nginx.conf and 2. nginx.conf.default

when I open the conf.default file it has a location / block where I can easily insert the code but since this is not the active configuration file I am forced to look into the existing nginx.conf file and insert code before any Location / block.

but this doesn’t help the plugin to verify the rewrite rules.

I am fairly a noob at this and require anyone with prior experience help solve this issue to verify the rewrite rules and further.

Here is the link to my nginx.conf file if it helps
(https://pastebin.com/W7gxi9dQ)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

I think that the Nginx config file that you’ve shared is for your PHPmyAdmin installation, this is why the rewrite rule might not be working. Otherwise, I believe that it is placed at the correct location in the config file.

As this does not look like a standard Nginx setup, are you using a specific control panel?

I believe that you need to find the correct Nginx server block file which is responsible for your WordPress website and add the rewrite rule there.

Regards,
Bobby