URL pointing to file without extension

There is a Mobile Optimized version of this page (AMP). Open Mobile Version.

I came across a very weird and extremely annoying “feature” of Apache recently when configuring a clients web server. When linking to a file on the server, you could directly link to a file without specifying it’s file extension.

so linking to:

http://mysite/favicon

Would link directly to:

http://mysite/favicon.ico

I can completely understand how useful this feature can be, and how it can help security. But I would expect a setting such as this to be defined in the .htaccess – not where I found it in the Apache Config file!!

And to cream the cake, the feature is called “MultiViews” – if you didn't know that, and didnt know where to look, you could be spending days / weeks / months trying to stop this behaviour, or change your code so that the site will function correctly.

 

How to disable!

All you need to do is edit your Apache Config file.

Find this:

<Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>

And delete MultiViews

Now your server will act as it is SUPPOSED TO!

Facebooktwitterredditpinterestlinkedinmail
Author: Dean WilliamsI'm a Web Developer, Graphics Designer and Gamer, this is my personal site which provides PHP programming advice, hints and tips

Post Tags:
, ,
00votes
Article Rating
Subscribe
Notify of
1 Comment
Inline Feedbacks
View all comments

thanks this was very usefull.