Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It really doesn't matter in my eyes because the web server in question will interpret the URL how it sees fit, even redirecting to a canonical URL (by adding a final slash or taking it away) if it feels like it.
For example, http://www.mysite.com/products/ may point at a directory on the web server, or a file, or some code, or whatever. It doesn't matter - the thing that matters is that the web server interprets it and you get web content in return.
Personally, my canonical URL form for my sites is to remove any trailing slash, but only for aesthetic reasons as I think it looks nicer that way.
Why are you guys having a side conversation in my thread?
I don't even understand what you were talking about with Ctl T and whatever?
Can we please get back to my OP and examples?
IMO the previous posts are on-topic and helpful...but if you want information about what happens on the server with and without a trailing / (and therefore how it might affect your mod rewrite), suggest you review the Apache documentation.
Also this search pulled up some useful information.
It really doesn't matter in my eyes because the web server in question will interpret the URL how it sees fit, even redirecting to a canonical URL (by adding a final slash or taking it away) if it feels like it.
For example, http://www.mysite.com/products/ may point at a directory on the web server, or a file, or some code, or whatever. It doesn't matter - the thing that matters is that the web server interprets it and you get web content in return.
Personally, my canonical URL form for my sites is to remove any trailing slash, but only for aesthetic reasons as I think it looks nicer that way.
But this is a big deal, because it affects how I am writing my mod_rewrites and regex!
This is my understanding...
Whether the hostname ends with a slash isn't really important, so either of these will do...
From my experience, it also depends on application itself. Although, most of the apps where I've noticed a trailing / is needed are all IIS/ASP applications.
Since, this is for your server and application developed by developers at your org, may be test or ask the developers weather or not a trailing / is required, that should help narrow down your options?
But this is a big deal, because it affects how I am writing my mod_rewrites and regex!
Well you should test your code. Write small portions of it to test and validate what happens for each condition you're worried about.
While I may solicit opinions from fellow developers or an online forum, I can assure you that while I may agree or disagree with offered opinions, I will always test my code. More helpful might be the additional perspectives given to me by other persons or posters which would help me to more completely test my code.
So while we get it that this is important, it is important to you, and thus rather than just take anyone's word for it, you should follow up on references offered to validate the information. And since you're writing actual code, I'll repeat the primary recommendation, which is to test it.
Also as scasey says, you can research a lot of this in the documentation.
In a "clean URL" which only has words and slashes, when should there be a trailing slash?
It essentially tells the web server that the url is of a DIRECTORY (on that server) and that it should load the default file IN that directory (often index.html, but other names could have been configured, like index.php). Some websites will not work without that trailing slash for a directory although other servers won't mind.
Of course an url which ends on a clear FILEname never should have a trailing slash.
Perhaps due to the URL format's UNIX-origins the trailing slash used to imply a directory and the lack of it implied a file, but that is no longer the case. It can be either or neither these days, the URL often pointing at nothing in particular, just providing some server-side code with an indication about which resource it should serve up.
In the practical world, just decide on how you want your URLs to be canonically and stick to it for the sake of consistency. Browsers won't give a hoot anyway if there is a trailing slash or not.
Well you should test your code. Write small portions of it to test and validate what happens for each condition you're worried about.
While I may solicit opinions from fellow developers or an online forum, I can assure you that while I may agree or disagree with offered opinions, I will always test my code. More helpful might be the additional perspectives given to me by other persons or posters which would help me to more completely test my code.
So while we get it that this is important, it is important to you, and thus rather than just take anyone's word for it, you should follow up on references offered to validate the information. And since you're writing actual code, I'll repeat the primary recommendation, which is to test it.
Also as scasey says, you can research a lot of this in the documentation.
I didn't ask what works. (Therefore tesing isn't the issue...)
I am asking what is the "right" way to do things. There is a difference.
And fwiw, I have been buried in the Apache manual for the last few days.
Of course, developers are horrible at documenting things, thus I have to ask here about things that the manual should tell me.
It essentially tells the web server that the url is of a DIRECTORY (on that server) and that it should load the default file IN that directory (often index.html, but other names could have been configured, like index.php). Some websites will not work without that trailing slash for a directory although other servers won't mind.
Of course an url which ends on a clear FILEname never should have a trailing slash.
In the past, that has been my understanding too...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.