Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running Apache 2.4.2 on my local server. My website's .htaccess file is as follows:

DirectoryIndex home.php
Options -Indexes
ErrorDocument 404 /404.php

This works great at displaying an HTTP 404 page when you try to access a non-existent file in the browser, but it is not showing the error page when accessing existing files using the following syntax:

http://localhost/<FileName>.php/<AdditionalCharacters>

For example, if I go to home.php/xyz, the home.php page loads, but all the relative links in the HTML are broken. I don't have a home.php directory on my server! What's going on?

Is there a directive or rule I can add to my .htaccess file to stop this behavior and throw an HTTP 404 error instead?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is a feature called "path_info", and is commonly used to run entire websites from a single CGI script (when better alternatives, such as mod_rewrite, are unavailable).

If the URL causes a CGI script to be treated as a directory, Apache will run that script normally but give it the extra path components in the PATH_INFO environment variable. Many wiki engines use this feature – for example, you can access https://wiki.archlinux.org/index.php/Beginners%27_Guide/Preparation this way.

This can be controlled using the AcceptPathInfo setting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.