Support » Fixing WordPress » Redirecting old, invalid URLs to 404 with mod_rewrite?

  • 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.

Viewing 1 replies (of 1 total)
  • 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"])) {

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

Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting old, invalid URLs to 404 with mod_rewrite?’ is closed to new replies.