How to redirect pages via htaccess when URL appears after the file extension?

52 views Asked by At

I already have htaccess redirection for all bad requests to custom/default 404 page:

ErrorDocument 404 /404.html

But still the site can be accessed like:
http://www.domain.com/index.html/http:/domain.com

It cause duplicate content issue and duplicate SEO tag issues. Any suggestions?

1

There are 1 answers

0
MrWhite On
http://www.example.com/index.html/http:/example.com
                                 |----------------|
                                    ^ path-info ^

This additional URL-path starting with a slash that follows the end of a URL that maps to a physical file is called "additional pathname information" (accessible in JavaScript through the Location.pathname property, or in PHP through the $_SERVER['PATH_INFO'] superglobal). Unless explicitly stated, whether it is accepted or not (on the server) is controlled by the handler for the request. However, it can be explicitly enabled/disabled with the AcceptPathInfo directive in your .htaccess file:

AcceptPathInfo Off

With it Off, then URLs that contain path-info will trigger a 404.

See also: