Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm having trouble accessing the stats sub-directory and get a 404 page not found. The file is there, I believe it has to do with the redirect for clean URLs for Drupal. The folder is there and the permissions are correct. So it must be the server configuration. Accessing the root of the stats folder and /stats/index.html does not work.

Directory listing with unrelated files omitted...

# ls -l /var/www/sites/omitted/stats  
total 508
r--r--  1 www  www    5310 Aug  7 07:31 index.html

The nginx server config...

server {
    listen 80;
    server_name omitted;
    access_log /home/john/access_log;
    error_log /home/john/error_log;

    location = / {
            root /var/www/sites/omitted;
            index index.php;

    location / {
            root /var/www/sites/omitted;
            index index.php;

            if (!-f $request_filename) {
                    rewrite ^(.*)$ /index.php?q=$1 last;

            if (!-d $request_filename) {
                    rewrite ^(.*)$ /index.php?q=$1 last;

    location /stats {
            root /var/www/sites/omitted/stats;
            index index.html;

    error_page 404 /index.php;

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
            root /var/www/sites/omitted;
            access_log off;
            expires 30d;

    location ~ \.php$ {
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME /var/www/sites/omitted/$fastcgi_script_name;
     fastcgi_param QUERY_STRING $query_string;
     fastcgi_param REQUEST_METHOD $request_method;
     fastcgi_param CONTENT_TYPE $content_type;
     fastcgi_param CONTENT_LENGTH $content_length;
     fastcgi_param PATH_INFO $fastcgi_script_name;
     include fastcgi_params;


I thought I just needed to create a "location /stats" block like the one in my config file.

Why does this not work? How do I solve it? Please explain the solution so I can learn something here.

share|improve this question
On a side note, this config has many mistakes in it (not related to your issue); see Nginx Pitfalls for some explanations. – Michael Hampton Aug 7 '13 at 16:52
The location directive specifying file extensions for static files just needed html. – John Tate Aug 7 '13 at 16:56
Thanks, I'll go through all those pitfalls. I can see I have a few. – John Tate Aug 7 '13 at 17:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.