How to make statistics and permalinks work with WordPress and Nginx


Nginx is a high performance web server used as an alternative to the popular Apache web server. WordPress works great on Nginx machines, however you need to adjust some files to get site statistics to work as they would on an Apache server.

This article shows you how to view your Analog stats after enabling stats in your DreamHost panel.

WordPress stats and Apache

Site statistics are not initially available when running WordPress. When WordPress is running on an Apache server, you can use an .htaccess file to allow the /stats subdirectory to serve your site statistics. View the following article for details:

WordPress stats and Nginx

After making any adjustments to a .conf file, you must restart your VPS or reload your Dedicated Server.

When using Nginx, your .htaccess file does not function. So you must add code to another file in order to view your stats. Your Nginx WordPress site has two directories:

In the following examples, username would be your Shell user and your website.

Your web directory (aka document root)

This is the directory where all of your website's files are located. 


Your nginx/ directory

This directory only contains configuration files for your site.


View the Nginx configuration file locations article for further details.

In this /home/username/nginx/ directory, create a file titled wordpress.conf. Add the following rule at the very beginning of this wordpress.conf file.

### stats
if ($request_uri ~* ^/(stats|failed_auth\.html).*$)

Now when you visit, a login prompt displays allowing you to log in and view your site statistics.

Enabling stats and permalinks

WordPress uses something called 'permalinks' to make the URLs easier to read. When running Nginx, add the following two sections to get both site statistics and permalinks to function.

### stats
if ($request_uri ~* ^/(stats|doc|failed_auth\.html).*$)
### permalinks
if (!-e $request_filename) {
  rewrite ^.*$ /index.php last;


If you've enabled a stats user on the Site Statistics page but find stats are still not accessible, please contact DreamHost support.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?