Alex Rivera | Logout

Why would you need a slash at the end of a URL?

Asked 2009-09-21T21:26:02.190
9

Is there a difference between these URLs in regards to having slashes at the end of the URL?

https://drchrono.com/about_us
https://drchrono.com/about_us/

Do web frameworks and web servers (e.g. Apache, Nginx, Django) handle these requests differently?

Edit
Report

1 Answer

28

The browser will treat them differently when it comes to relative URLs. A page at:

http://server/path

with a relative link like:

<a href='other'>

will resolve that link to:

http://server/other

replacing path with other. Whereas if the starting URL was:

http://server/path/

then the resolved link would be:

http://server/path/other

If path is a directory rather than a file, most web servers will automatically redirect from:

http://server/path

to:

http://server/path/

because that's almost certainly what you meant.

answered 2009-09-21T21:29:31.360

Your Answer