Redirect from dotted pages

http://web-site.com/index.phpsad 

404 page

 http://web-site.com/404 

    1 answer 1

    The very formulation of the problem is fundamentally wrong

    It would be better to do so:

    • If the page does not exist, but we have a new suitable page with very similar content, then we can redirect with the status code 301, as if to say "moved forever."
    • If the page does not exist, and we have no idea why someone typed a never existing or incorrect URL in the address bar, then it is necessary to return the status code 404 "not found". This means that you entered the wrong URL and someone gave you a wrong link. From this page you should not make automatic redirects to other pages. Instead, it is better to place a link to the main page so that the user can choose what to do next.
    • If the page does not exist, but we reliably know that once there was such a page, but now it does not exist and will not be in the future (we decided that we don’t need such a page anymore), then it is necessary to return the status code 410 “deleted” from a link to the main page so that the user can decide what to do next.

    Redirecting the status code 301 to the page with the 404th error is wrong . It does not have the most similar content that does not exist now. You should immediately return the 404th error when accessing such addresses. Gluing non-existing addresses with the 404th error will not give anything in SEO.

    HTTP status codes do not just exist, this is a standard that should be followed.

    In the description of the standard and on the wiki you will find more information.
    Read the article from Google: " Do 404s hurt my site? "

    Solution to your problem

     RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule [.] /404 [L] 

    This will process all pages that contain a dot in their address, except for existing files and folders with a dot in their name.

    An example of the script:

     /test.sub/ # Не существующий раздел - 404 Not Found /test.h # Не существующий файл - 404 Not Found /catalog.example/ # Существующий раздел - 200 OK /index.html # Существующий файл - 200 OK 

    The answer used the information from the answer to the question: " SEO - 301 redirect via 404 page "