Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference between domain.com/folder and domain.com/folder/

Tags:

html

browser

web

I've been told that these both behave different in terms of loading resources on the page

http://domain.com/folder
http://domain.com/folder/

However I've also noticed that no matter what I do, the browser redirect http://domain.com/folder to http://domain.com/folder/

So I wanted to ask -- what's the major difference between the two? What should I do for my browser to not redirect (or add the end slash)

like image 482
Mia Avatar asked Nov 09 '22 02:11

Mia


1 Answers

They are different URLs. The biggest difference between them is that URLs consisting of relative paths will resolve from http://example.com/ for one and http://example.com/folder/ for the other.

However I've also noticed that no matter what I do, the browser redirect

No, it won't.

Given a path that the HTTP server resolves as a static directory on the file system, the default configuration of most HTTP servers is to send an HTTP redirect to add the / on the end.

It is the server redirecting, not the browser.

How you change that depends on the server, not the browser.

What should I do for my browser to not redirect (or add the end slash)

Generally speaking, you shouldn't. That's normal behaviour. (And, as mentioned, it depends on your server.)

If the changing path is causing problems for relative URIs, then use relative URIs with absolute paths in them (i.e. which start with a /).

like image 91
Quentin Avatar answered Dec 17 '22 00:12

Quentin