Send 404 when requesting index.php through .htaccess?

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-05-08T19:23:08Z Indexed on 2010/05/08 19:28 UTC
Read the original article Hit count: 196

Filed under:
|
|

I've recently refactored an existing CodeIgniter application to use url segments instead of query strings, and I'm using a rewriterule in htaccess to rewrite stuff to index.php:

RewriteRule ^(.*)$ /index.php/$1 [L]

My problem right now is that a lot of this website's pages are indexed by google with a link to index.php. Since I made the change to use url segments instead, I don't care about these google results anymore and I want to send a 404 (no need to use 301 Move permanently, there have been enough changes, it'll just have to recrawl everything).

To get to the point: How do I redirect requests to /index.php?whatever to a 404 page? I was thinking of rewriting to a non-existent file that would cause apache to send a 404. Would this be an acceptable solution? How would the rewriterule for that look like?

edit:
Currently, existing google results will just cause the following error:

An Error Was Encountered

The URI you submitted has disallowed characters.

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about codeigniter