Forum Moderators: phranque
www.domain.com/file.htm/file
I do have a www.domain.com/file.htm on the site, and what I see when I go to the url is file.htm's contents, although the style sheet and other relative redirects don't show. Server header checker reports a 200 OK response. (oddly enough, this will happen if you try this with a file on WebmasterWorld.)
I tried to request this same scenario on a site with a different Apache server, and got the proper 404 error.
Does anybody have any ideas for configuring Apache to get a proper 404 error in this situation?
The work-around is fairly ugly, and relies on using Apache mod_rewrite [httpd.apache.org] to rewrite the request to a (another) file that is known not to exist.
Options +FollowSymLinks
RewriteEngine on
RewriteRule \.[^/]+/ /file_that_does_not_exist [L]
You might also consider doing a "fix-up" redirect on this type of URL:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.+\.[^/]+)/ http:www.example.com/$1 [R=301,L]
Whether either of these work without interfering with your other URLs depends on whether you have any other URLs where a slash does follow a filetype. Since you didn't mention this, I assume not.
You may not need one or both of the first two lines of either example; they're only needed if these configurations are not already set in httpd.conf or your current .htaccess file.
[added]
A third alternative is to use the 410-Gone response, but this is only useful for HTTP/1.1 (and later) clients:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteRule \.[^/]+/ - [G]
Jim