ScotWatson
New Member
- Messages
- 13
- Reaction score
- 0
- Points
- 1
I am working on an API and I have come across the issue of trailing slashes. So far, I have been storing the php code for each endpoint into a file called index.php in a folder with the name of the endpoint. When I try with the trailing slash, I get the response generated by the php code. When I try without the trailing slash, I get a 301 (Permanently Moved) redirect, then the request and response I get with the trailing slash. I did some research and found that this behavior can be obtained with certain commands in the .htaccess file, but I do not have any of those commands in that file. Is it standard for servers to behave this way? Is it possible to change this behavior?
Web searches seem to reveal that although there is no official standard, it seems like there is a de facto standard to not use trailing slashes in APIs. Even if the behavior is turned off, in order to not have a trailing slash, I would need a file with the name of the endpoint and no file extension, but then it would not have a php extension, so the code would never get interpreted. So I am not sure how to support not having a trailing slash without an intermediate redirect.
Sorry for the long post, but these questions seem too closely related to make them separate.
Web searches seem to reveal that although there is no official standard, it seems like there is a de facto standard to not use trailing slashes in APIs. Even if the behavior is turned off, in order to not have a trailing slash, I would need a file with the name of the endpoint and no file extension, but then it would not have a php extension, so the code would never get interpreted. So I am not sure how to support not having a trailing slash without an intermediate redirect.
Sorry for the long post, but these questions seem too closely related to make them separate.