JayDub
JayDub

Reputation: 13

Htaccess file to strip characters from URL

I'm trying to strip characters from spam links to pages that don't exist on my site.

I have this in my htaccess file:

ErrorDocument 404 http://www.example.com/

Basically, I'm trying to remove the ability for users to get to my site via links like www.example.com/index.php/anythingtheyenter

Since index.php exists and is my homepage, for some reason apache will keep the trailing /anythingtheyenter

in the address bar and any futher clicks into the site will retain that /anythingtheyenter.

I would think that since the /index.php/anythingtheyenter is not a real page it would use the 404 redirect, but that isn't happening.

Any ideas what I could change in the htaccess to make this truly redirect to the actual www.mysite.com/index.php?

Thanks, Jay

Upvotes: 1

Views: 73

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Add the following line to htaccess :

AcceptPathInfo Off

This tells the server to deny a trailing path after an existent file.

You will get a 404 error if a file with trailing path eg: (/file.php/path) is requested.

Upvotes: 1

Related Questions