Silverstripe URL Rewrites Still Allow /index.php/ urls

Your friendly URLs may be working correctly to serve /news/category/page1 for instance, but it can also serve that same page from /inde.php/news/category/page1. The problem that I found is that Google somehow indexed a large amount of pages that included /index.php/ in the URI. To fix, you simply need to redirect all the requests from /index.php/ folder to the root, preserving the string after that folder.

Add these two lines to your .htaccess file, before the ### Silverstripe Start ###:

RewriteRule ^index\.php/(.*)$ /$1 [R=301,L]
RewriteRule index\.php / [R=301,L]

The first line above will redirect requests from the /index.php/ “folder” to the root. The second will redirect any requests direct to /index.php to the root /