WordPress: Fix “No input file specified” error with index.php in permalink

Some time ago we changed our permalink address for our wordpress blog from something like https://www.mydomain.com/blog/index.php/2015/09/20/some-post/ to https://www.mydomain.com/blog/2015/09/20/some-post/ to get rid of the index.php part. Since it takes some time for google to crawl all the pages again, the deprecated links were still shown in the search results. Unfortunately all the links lead to a “No input file specified” error.

The fix for this is easy.

If you are able to edit or create a .htaccess file and your server supports URL rewrites (mod_rewrite module for apache, which is very common) just add some lines like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^blog/index.php/(.*) /blog/$1 [R=301,L]
</IfModule>

This will tell a browser or even the google crawler that a webpage moved from /blog/index.php/something to /blog/something/.
If you already have rewrite rules in your .htaccess file (e.g. the permalink rewrite rules of wordpress) just put these lines at the very beginning of your rewrite rules.

Tagged with: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*