Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: 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 in a browser, the data is served but the URL in the address bar changes to while it was supposed to stay

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

share|improve this question

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.