Below is a much simplified version of what I have in the configuration file of a server run by Nginx 1.2.5, yet it causes 301 Moved Permanently with Location: http://example.com/phpmyadmin/ before serving data, which is not what I expected from the default behavior of the rewrite directive.

server {
    listen 80;
    location /pma {
        rewrite ^ /phpmyadmin;
    location /phpmyadmin {
        root /var/www;
        index Documentation.html;

(Again, the example is highly simplified and altered, the config makes perfect sense in its original form.)

When I go to http://example.com/pma in a browser, the data is served but the URL in the address bar changes to http://example.com/phpmyadmin/ while it was supposed to stay http://example.com/pma.

How do I avoid Nginx sending 301 Moved Permanently so that it doesn't expose the actual directory structure on my server?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.