Why rewrite directive causes "301 Moved Permanently" with Nginx?
- by Desmond Hume
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;
}
}
When I follow http://example.com/pma, the data is served but the URL in the browser is changed 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?