KBD

Keith Devens .com

Thursday, November 20, 2008 Flag waving
This is not The Greatest Song in the World, oh no. This is just a tribute. – Tenacious D
← Digital IQ quizDon't "feel"... THINK →

Daily link icon Tuesday, December 9, 2003

Apache directory slash adding

How do you keep Apache from automatically adding a trailing slash for directories? For instance, when you go to a URL like http://example.com/2003/12/08, Apache sticks a slash on the end to make it http://example.com/2003/12/08/.

Is there any way to keep it from doing that?

← Digital IQ quizDon't "feel"... THINK →

Comments XML gif

Donncha O Caoimh (http://blogs.linux.ie/xeer/) wrote:

Probably the best way is to use mod_rewrite as Apache will hand over the url to your mod_rewrite recipe/code where you can do whatever you like to it.

∴ Donncha O Caoimh | 9-Dec-2003 9:55am est | http://blogs.linux.ie/xeer/ | #3483

Nathaniel (http://www.thornvalley.com) wrote:

Out of curiosity, why would you want to? (and yes, mod_rewrite is probably the answer, though I haven't really used it myself, and wouldn't know what rules to feed it)

∴ Nathaniel | 9-Dec-2003 10:35am est | http://www.thornvalley.com | #3488

Keith (http://keithdevens.com/) wrote:

I figured I could do it with mod_rewrite, but I was hoping there was some other way. I have to learn more about how Apache handles directories... from what I was reading, there is a definite reason why Apache behaves the way it does.

why would you want to?

Just a personal preference... I don't like URLs to end in a slash. Check out all the URLs I use on my site.

Keith | 9-Dec-2003 1:14pm est | http://keithdevens.com/ | #3490

Chris (http://today.icantfocus.com/blog/) wrote:

I'm still confused why you want to.
Not using trailing slashes for directory cause 2 trips to the server for all web clients: once for "/directoryfoo", which receives a "Location: /directoryfoo/" redirect response header, then a second request to the server for "/directorfoo/".

I believe this is a standard behaviour even on IIS on windows.

∴ Chris | 9-Dec-2003 8:11pm est | http://today.icantfocus.com/blog/ | #3495

Chris (http://today.icantfocus.com/blog/) wrote:

Shoot. I can't type this evening, but you get the idea.

∴ Chris | 9-Dec-2003 8:11pm est | http://today.icantfocus.com/blog/ | #3496

Keith (http://keithdevens.com/) wrote:

Not using trailing slashes for directory cause 2 trips to the server

Yeah. That's why I'm not going to worry about it. However, if I used mod_rewrite, or, like I do on my site, a CMS that resolves URLs on its own, it wouldn't need the extra redirect.

Keith | 9-Dec-2003 8:19pm est | http://keithdevens.com/ | #3497

Chris (http://today.icantfocus.com/blog/) wrote:

Something else to try: MultiViews. I know it does some predefined mod_rewrite magic to make /foo hit /foo.htm, or /foo.htm.en. I've never tried it with directory names, but it may "just work".

∴ Chris | 9-Dec-2003 8:21pm est | http://today.icantfocus.com/blog/ | #3498

Daniel Lorch (http://daniel.lorch.cc/) wrote:

Behaviour is determined by mod_dir:

http://httpd.apache.org/docs/mod/mod_dir.html

An interesting, related Directive is "UseCanonicalName":

http://httpd.apache.org/docs/mod/core.html#usecanonicalname

∴ Daniel Lorch | 10-Dec-2003 2:47pm est | http://daniel.lorch.cc/ | #3502

RV (http://rv.atomo.info/rv_en.php) wrote:

you can change the status of the directive UseCanonicalName to Off in the httpd.conf file...

∴ RV | 6-Sep-2004 9:04pm est | http://rv.atomo.info/rv_en.php | #5531

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.161s.

(Used 8 db queries)

mobile phone