2

We're having a problem with our PHP site: http://midlandssmilecentres.co.uk/

The problem is as follows, if you were to access, for example http://midlandssmilecentres.co.uk/feedback.php, and then put a trailing slash, it returns the index page of the root directory. From there, you can actually put any page, i.e. http://midlandssmilecentres.co.uk/feedback.php/feedback.php, and it will return that page. We need this behaviour to stop, or a feasible work around to stop these pages being accessible.

This is causing us lots of problems with duplicate content and pages that haven't been mobilised, due to the page trying to fetch the CSS from the wrong directory. We've tried removing all of the .htaccess files on the server, however this has not fixed the issue. I've done plenty of research on files with trailing slashes and how a file can be interpreted as a directory, but couldn't find anything that could help me with this.

Dan
  • 33
  • 4
  • 2
    I think I recall this happening once for us 15 years ago, but I've totally forgotten what was done to fix it. I think its an apache setup issue (htaccess wouldn't be the issue, and php definitely isn't doing it). Are you running apache? or a different webserver? – IncredibleHat Nov 07 '17 at 15:24
  • Our domain is a Linux based one with Godaddy, and I've tried contacting them, but they had no idea. – Dan Nov 07 '17 at 15:53

2 Answers2

2

With .htaccess, you can redirect all .php/... pages:

RewriteEngine on
RewriteRule ^(.+?\.php)/ $1 [NC,L,R=301]

You also can change the apache configuration with:

AcceptPathInfo Off

But in this case a 404 error will be returned
https://httpd.apache.org/docs/2.2/mod/core.html#acceptpathinfo

Croises
  • 18,570
  • 4
  • 30
  • 47
  • 1
    Great! That stopped the issue. Do you have any idea why this was happening? It would be nice to understand why it happened and if there's a way to stop it at the source. – Dan Nov 07 '17 at 15:49
  • I think it's often related to a bad url entry in a page or by a user. – Croises Nov 07 '17 at 15:55
  • But there's nothing at http://midlandssmilecentres.co.uk/feedback.php/feedback.php, that directory doesn't exist and that file doesn't exist, putting that into a web browser should return the 404 page. I don't understand how a bad url entry could cause that page to somehow exist? – Dan Nov 07 '17 at 15:57
  • Not normally everything after the slash is ignored. With the addition of a problem of relative bad links. – Croises Nov 07 '17 at 15:59
-1

I think you need to set a 404 REDIRECT, so instead of returning that page, it redirects to a 404 page.

Excellent Lawrence
  • 946
  • 11
  • 11
  • We have a 404 page set, if for instance you enter http://midlandssmilecentres.co.uk/feedb it takes you to that page. The problem here is that a file with a trailing slash is being interpreted as a directory, that goes to the root. – Dan Nov 07 '17 at 15:48