1

I am trying to configure Nginx so that I can access PhpMyAdmin from a subdirectory (aka domain.com/phpmyadmin). The code provided below seems to work for me although I don't want the alias to be /phpmyadmin.

location /phpmyadmin {

       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/phpmyadmin/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               fastcgi_pass 127.0.0.1:9000;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include /etc/nginx/fastcgi_params;
       }
       location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
               root /usr/share/;
       }
}

If I try to change the location name from

location /phpmyadmin { ...

to...

location /secret { ...

everything seems to break. What am I doing wrong?

Danafer
  • 11
  • 3

1 Answers1

1

You should use an alias instead:

location /mysecretdirectory {
    alias /usr/share/phpmyadmin/;
}
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940