[resolved] I wish to block hits to /blog/index.php/index.php (5 posts)

  1. hetta
    Posted 9 years ago #

    I get a few /blog/index.php/index.php?paged=18 requests a week; the relative links to other parts of my site all return 404s if clicked from such an URL.

    How do I block these, serve them a 404 right off, or send them to /blog/index.php?... ?


  2. VaamYob
    Posted 9 years ago #

    You can use a rewrite rule to rewrite

    blog/index.php/index.php?... to blog/index.php?...

    (I'm just typing, this is close, but probably not exactly correct)

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

  3. hetta
    Posted 9 years ago #

    Good idea, but for some reason .htaccess rewrite doesn't work on my site (which is why I don't have pretty permalinks).

    Can I add some .php to wp-blog-header.php?

    I tried putting this right after <?php in wp-blog-header.php, but that did nothing at all:
    if (strpos($REQUEST_URI, 'index.php/index.php') > 0) { exit; };


  4. VaamYob
    Posted 9 years ago #


    if (strpos($_SERVER[REQUEST_URI], 'index.php/index.php') > 0) { exit; };

    You may have just been using the above code for testing/troubleshooting, but if you weren't, exit; may be a bit too extreme of an action to take. Maybe you could just redirect them to the main index.php

    if (strpos($_SERVER[REQUEST_URI], 'index.php/index.php') > 0) {
    header("Location: http://www.yourdomain.com/blog/index.php \n\n");

    If you chose to do it this way, you'd want to make sure this is one of, if not the first lines of code in index.php.

  5. hetta
    Posted 9 years ago #

    Many thanks! Pasting that right after <?php in wp-blog-header.php
    did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic