Forum Moderators: phranque

Message Too Old, No Replies

Weird behavior - help

         

silkfire

6:25 pm on May 14, 2010 (gmt 0)

10+ Year Member



Can someone design some htaccess code for me that denies users to this behavior:

I have some php files on the server, for example one is "poster.php". Currently I can access this page by entering "www.example.com/poster/" or even "www.example.com/poster/fgfdgd" even if that shouldn't be valid address. Is it possible to redirect such attempts to a 404 error?

g1smd

6:32 pm on May 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Turn off MultiViews and/or AcceptPathInfo.

silkfire

10:39 pm on May 14, 2010 (gmt 0)

10+ Year Member



I have Apache 1.3.x and don't have access to AcceptPathInfo. What's the mod_rewrite alternative?

jdMorgan

11:13 pm on May 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need an alternative, because if you had AcceptPathInfo, you'd want to turn it off.

Since you don't have it, all that remains to be done is to disable MultiViews using the Options directive.

Jim

silkfire

11:35 pm on May 14, 2010 (gmt 0)

10+ Year Member



It worked out but if I enter the URI with the extension and slash after it still finds the file.

"www.example.com/poster.php/sdgfdfsdf"

gives me -> poster.php

"www.example.com/poster/sdgfdfsdf"

now correctly gives 404 though (no directory called "poster" even exists).

jdMorgan

12:11 am on May 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So, in the absence of AcceptPathInfo and content-negotiation, how are URL requests mapped/forwarded to your script? -- Is there some code in your .htaccess file, and if so, what is it?

Jim

silkfire

12:36 am on May 15, 2010 (gmt 0)

10+ Year Member



My .htaccess looks like this:


Options +FollowSymLinks -MultiViews
ErrorDocument 404 /404.php

AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm

<FilesMatch "\.(pdf|PDF)">
ForceType application/pdf
Header set Content-Disposition attachment
</FilesMatch>

RedirectMatch 404 "(index$|index.p$|index.ph$)"

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php|html)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.example.com/$1 [R=301,L]

jdMorgan

4:13 pm on May 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see anything here that would map requests for "www.example.com/poster.php/sdgfdfsdf", to your script -- that URL request should be treated as a request for the extensionless file "sdgfdfsdf" in the subdirectory named "/poster.php".

Look through your "control panel" settings and if there's nothing in there related to this problem, all I can recommend is that you ask your host.

You could apply a "band-aid" by adding a rewrite rule to look for "slash and path following poster.php" and forcing a 404, but covering up problems usually leads to even worse --and even "unfindable"-- problems later.

I strongly recommend that you identify the root cause of this behaviour before considering adding any work-arounds.

Jim