Forum Moderators: phranque

Message Too Old, No Replies

Apache don' t understand the diff between /2008-03/ and /2008-03.html

         

Markus Klaffke

9:43 am on Jun 11, 2008 (gmt 0)

10+ Year Member



On my Apache 2 is content-negotiation enabled. User can access webpages with

http://example.nu/index

or

http//example.nu/index.html

That might be the problem, but i don' t know.

I have reworked my blogs archives and created a folder structure like this

/2008-06/index.html
/2008-07/index.html

which are SSI files.

Under document root i have files like

2008-06.html
2008-05.html
2008-05-title-of-the-blogpost.html

which are the real monthly archives or individual posts with executed SSI, it is more or less a cache.

Ok, the problem is now that i am unable to access the html files. Access to the monthly archives is always "redirected" to the folder with nearly the same name. In other words, trying this

http://example.nu/2008-05.html

or

http://example.nu/2008-05-title-of-the-blogpost.html

would be redirected by Apache to

http://example.nu/2008-05/

which is wrong since there are only the raw files.

It would be very simple to rename the folders. But why should i? Is it possible to return a 404 if someone tries to access /2008-06/ and if how could this be done? I tried it, but all results are nonsens.

[edited by: Markus_Klaffke at 9:47 am (utc) on June 11, 2008]

jdMorgan

4:07 pm on Jun 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do not enable content-negotiation and/or AcceptPathInfo unless you actually need them to make your site work. If you do need them, then it will be up to you to name files and folders so that conflicts do not occur.

To produce a 404 on a URL request, rewrite that URL to a non-existent filepath in the root directory of your site. (The only reason it has to be in root is to try to prevent content negotiation from interfering.)

To produce a 403-Forbidden on a directory access request, use "Options -Indexes" in .htaccess or in a directory container in httpd.conf/conf.d

The best solution to these types of problems is to turn off features you don't need, or that cannot be replaced with a more-controlled option (such as a few mod_rewrite rules replacing content negotiation). And above all, for long life and happiness, keep things simple, with very few dependencies.

Jim