Nginx Configuration (Nginx Server)

Nginx is an open source web server like Apache. If you can’t find any htaccess file in your server or there is a /index.php/ before your WP permalinks this (usually) means your server uses Nginx. In such case you’ll need to configure Nginx configuration file manually. To do so you need root access and basic SSH knowledge.

In HMWP settings page (Start tab) you should see “Nginx Configuration” button. If you don’t see this button and you are sure that it is an Nginx server then use URL like below to see Nginx rewrite rules. For example:

www.YourDomain.com/wp-admin/options-general.php?page=hide_my_wp&die_message=nginx

If you use sub-directory for WP server block you should add that directory before all of rules. You need this change only if your server block in Nginx is based on sub-directory. Assume the sub-directory is ‘mywp’. Here is some example:

rewrite ^/mywp/template/lib/(.*) /mywp/wp-includes/$1 last;
rewrite ^/mywp/storage/(.*) /mywp/wp-content/uploads/$1 last;
rewrite ^/mywp/ext/aa405a34/(.*) /mywp/wp-content/plugins/akismet/$1 last;
rewrite ^/mywp/ajax /mywp/wp-admin/admin-ajax.php last;
rewrite ^/mywp/(readme\.html|wp-includes/$) /mywp/nothing_404_404 last;
rewrite ^/mywp/(index\.php|wp-content/repair\.php|index\.php|wp-admin/)(.*) /mywp/$1$2 last;
rewrite ^/mywp/(.*).php$ /mywp/nothing_404_404 last;

You’ll need to add HMWP rules to your Nginx configuration file. Nginx config file is usually located in /etc/nginx/nginx.conf or /etc/nginx/conf/nginx.conf (ask your hosting provider if you are not sure about the location of Nginx config file). Make sure that you add the rules in server{} block. Then finally restart Nginx server.

You can find the video tutorial here.

Note: You’ll need to update Nginx config file (overwriting previous HMWP rules) whenever you make any changes to HMWP settings, or install new plugin/theme.

Note: To configure HMWP in WP Engine platform, please check this video tutorial.

Was this helpful?

Previous Article

htaccess (Apache Server)