Apache file directories on Ubuntu

Asked by Matt B

I wonder whether anyone can help me with this problem that I have just come across.

I am running Apache 2 on Ubuntu 6.06 and I have just noticed that if, by accident, I type a folder name (which doesn't exist) using the same name as a file name within the same website Apache serves this as the index file of a new folder with the same name as the mis-typed folder.

Apologies for the somewhat confusing explanation - hopefully this will clarify: -

On website 'great_information', I have a file called 'contact.html' in the main directory.

If I accidentally type 'great_information/contact/' in the location bar instead of 'great_information/contact.html' the browser returns the contact.html page as the index file of a folder called 'great_information/contact/' (which doesn't exist).

Then, in turn, all of the relative links within this new index page relate to pages within the 'new' folder and even more bizarrely if you click on them the server returns the same page (the contact.html page) for each of the links with the location bar showing them as different pages (e.g. 'great_information/contact/more_info.html'; 'great_information/contact/even_more_info.html' and so on).

This seems extremely strange and could cause major problem in terms of navigation if a simple error was made typing into the location bar (of course, in theory, you're not expecting your users to type the URLs directly in to the navigation bar, but it could happen).

Presumably this is something to do with the web server configuration but I cannot find a way to prevent this happening.

Anyone have any thoughts on this?? Any help greatly appreciated.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apache2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
François Tissandier (baloo) said :
#1

Weird problem... First time I see this.

Did you check if there are any "DirectoryIndex" parameters in your apache2.conf file, then in the configuration files for your websites?

Also, it could be a modrewrite command. Did you check for .htaccess files?

Revision history for this message
Matt B (admin-mdbwebdata) said :
#2

Thanks for contacting me.

Well, I'm not an expert on Apache but all I can see in the apache2.conf file relating to "DirectoryIndex" parameters is the following: -

index.html index.cgi index.pl index.php index.xhtml

Which makes sense to me.

I don't believe I have any mod rewrite commands in place (I'll double-check) - certainly nothing is showing in the .conf file. Or in any htaccess files.

I have to say, I am a bit baffled??!!??!!

The ??!!??!! means extra-baffled!

Any other thoughts?

Thanks, again, for your help.

Revision history for this message
Matt B (admin-mdbwebdata) said :
#3

Actually - I've just noticed something. My first comment wasn't quite true. The server isn't turning .html files into folders only .php files. Most of my files are php files and I took it that they would operate similarly to html files - obviously incorrectly.

So, if I accidentally type 'great_information/contact/' in the location bar instead of 'great_information/contact.php' the browser returns the contact.php page as the index file of a folder called 'great_information/contact/' (which doesn't exist). But if, for example, I accidentaly type 'great_information/news_page/' instead of 'great_information/news_page.html' then the browser returns a 404 Not Found error (correctly).

So it appears to be converting the php to directories not the html files.

Still very odd.

Revision history for this message
François Tissandier (baloo) said :
#4
Revision history for this message
Matt B (admin-mdbwebdata) said :
#5

No - I hadn't. But this does look like it might be the cause - although not 100% sure - the article doesn't discuss this odd situation where instead of miss-typing 'contact.php' straightforwardly as 'contact' you miss-type it as 'contact/'.

Which, in the end, causes quite a problem.

I guess I need to turn multi-views off - which must be on by default? Although it clearly does have the benefit of finding the correct file if the file extension is just left off but is a big problem if someone accidentally adds a '/'.

Very interesting.

Thanks for that. Very impressed. I haven't actually come across this before. And I certainly hadn't even thought of the Google-bot situation (I haven't noticed loads of errors on the web server logs but had better check now!).

Revision history for this message
François Tissandier (baloo) said :
#6

Hi Matt B. Any update on your problem? Is it working? I'm curious to know the exact reason.

Revision history for this message
Matt B (admin-mdbwebdata) said :
#7

Hi Francois - apologies for the delay in replying to you.

No - I am afraid I haven't found a solution to this problem.

The multiviews option seems a good thing but this odd result certainly is a problem - although unlikely to be encountered too often.

I guess the only way to resolve it is to turn of this option - no other ideas really. If you have any I would love to hear about them!

Matt

Revision history for this message
François Tissandier (baloo) said :
#8

Are you sure you are not using mod_rewrite? Thanks to .htaccess files maybe?
Check if the module is activated also.

Revision history for this message
Matt B (admin-mdbwebdata) said :
#9

As far as I can tell I'm certainly not using mod_rewrite and can't find any .htaccess files.

I've used both before on different servers and have never noticed this problem.

When you say, "Check if the module is activated also", do you mean the mod_rewrite?

Revision history for this message
François Tissandier (baloo) said :
#10

Yes mod_rewrite.

I guess I'm running out of reasons then, sorry Matt...
Anybody else here with bright ideas? :)

Can you help with this problem?

Provide an answer of your own, or ask Matt B for more information if necessary.

To post a message you must log in.