Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

You should use an alias instead:

location /mysecretdirectory {
    alias /usr/share/phpmyadmin/;
}
share|improve this answer
    
I tried that already and restarted nginx, hoping that it would be as easy as I thought. Instead, I get a 403 error :( –  Danafer Jan 7 '13 at 18:19
    
So check your error logs and find out why. –  Michael Hampton Jan 7 '13 at 18:36

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.