curl 301 moved permanently if I don't use slash at the end of the url

c4rl nginx-forum at forum.nginx.org
Tue Mar 28 16:56:13 UTC 2017


Hi,

I need to list the content of some directories with curl without to use a
'/' at the end of the url.

If I do not use the slash then I receive the message below, otherwise the
content is showed. I tried many rewrite rules without success.

[user at localhost ~]$ curl http://mydomain.example.com/data/foo

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>


[user at localhost ~]$ curl http://mydomain.example.com/data/foo/

<html>
<head><title>Index of /data/foo/</title></head>
<body bgcolor="white">
<h1>Index of /data/foo/</h1><hr><pre><a href="../">../</a>
<a href="57581/">57581/</a>                                            
12-Jul-2016 01:56                   -
<a href="57582/">57582/</a>                                            
13-Jul-2016 01:55                   -
<a href="57583/">57583/</a>                                            
14-Jul-2016 00:34                   -
</pre><hr></body>
</html>


This is my vhost configuration:

server {
     listen 80;
     server_name mydomain.example.com;
     access_log /var/log/nginx/mydomain.example.com-access.log;
     error_log /var/log/nginx/mydomain.example.com-error.log error;

     location /data/foo {
             alias /data/foo;
             autoindex on;
     }

     location /data/bit {
             alias /data/bit;
             autoindex on;
}


Thanks.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273267,273267#msg-273267



More information about the nginx mailing list