WordPress.org

Ready to get started?Download WordPress

Forums

Redirecting old, invalid URLs to 404 with mod_rewrite? (2 posts)

  1. carbeck
    Member
    Posted 3 years ago #

    Hi!

    I've recently replaced my old page with a brand new WordPress installation. Now the thing is, my old URLs with index.php?go=, ?i=, and ?w= are now invalid, and I'd like to send 404s so that they vanish from search engines. The problem is, that WordPress will send the front page with 200 if you enter any of those old query codes, so spiders will only register that the content of the URL has changed, but not that it's not valid anymore.

    As I understand it, the RewriteCond for that would be %{HTTP_REFERER} ^.*/(index.php)?\?(go|w|i)=.*$, but what do I write in the RewriteRule? A simple .* - [R=404] won't do, because then I either get a 500 error for the whole page, or the HTML of the front page is still returned (with 200), with only the images, CSS etc. declared 404.

    I'm confused and glad for help.

  2. carbeck
    Member
    Posted 3 years ago #

    Tentatively I've included the following code in ./wp-content/themes/twentyten/header.php now:

    if(preg_match("/\/(index.php)?\?(go|w|i)=.*/i", $_SERVER["REQUEST_URI"])) {
    	http_send_status(410);
    	die;
    }

    I'd still be more comfortable if I didn't have to mess with template files.

Topic Closed

This topic has been closed to new replies.

About this Topic