Nginx is currently doing the following:
example.com/folder
301 redirect to:
example.com/folder/
How can I prevent it from doing this?
Thanks.
Edit: Added Nginx configuration
server {
server_name www.example.com;
listen *:80;
listen [::]:80 ipv6only=on;
return 301 http://example.com$request_uri;
}
server {
server_name example.com;
listen :80;
listen [::]:80;
root /home/usr/www;
index index.htm;
location ~ .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
folder
. The only way to get rid of the slash at the end would be to force all request to go through 1 file (e.g. index.php) and then make your application routing logic work through that. But I think this is overkill. Can you comment more on what exactly you want to achieve with this or solve?file
and when it find directory, it redirects tofile
directory and looks for default (usuallyindex.html
) file. If you do not want 301 redirect, then you have to point your links todomain.com/folder/
. Otherwise - you can only achieve what you want programically and not only with nginx configuration update. As you would need a a single point controlling all the routing logic. This is how it is usually done.