How to setup Hide My WP on Nginx server

If your server is a Linux server, the main path to the nginx.conf file is /etc/nginx/nginx.conf (or /etc/nginx/conf/nginx.conf if you’re using Arch Linux). If the server is a Windows server your nginx.conf file will be located at C:nginxconfnginx.conf)

If your nginx doesn’t have sites-enabled option activated (check for sites-enabled subdirectory in the same directory with nginx.conf file), you will find the server configuration in nginx.conf file like in the below example:

server {
        server_name [your domain name];
        root [path to the website root];
        index index.php;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

}

Now, if you change the settings in Hide My WordPress to ninja mode, you will be asked to add the code in nginx.conf file.

What you have to do is to add the code after “try_files $uri $uri/ /index.php?$args;” line. See the below example:

server {
        server_name [your domain name];
        root [path to the website root];
        index index.php;
        include path-to-file/hidemywp.conf;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }

}

If you nginx has the sites-enabled option activated you have to enter in the sites-enabled subdirectory and open the file with the domain name. In that file you will find the above configuration.

Note: Don’t delete any line from your current configuration unless you know what you are doing.  

After you add the lines in your conf file, save it and go back to your Hide My Wp settings and press the “Okay, I set it up” button. Logout and check if the new URLs are set correctly by checking the source code.

Note: You need to reload the Nginx config to apply the changes.

For  linux use:

# nginx -s reload

For  Windows use:

# cd C:nginx
# nginx -s reload

See Also: How To Configure Hide My Wp On Nginx Web Server With Virtual Private Server

John Darrel

I am a WordPress Developer and I love creating plugins and themes for WordPress. It is a great CMS for any kind of business but we need to keep it a safe place.

I have over 10 years experience in building plugins and themes for WordPress and other platforms.

Contact me if you have plugins that you want me to check before you insert them in your website. I will be happy to check them for security and speed.

Leave a Reply

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