.htaccess issue

software development


I hope this is the correct forum, it seemed as appropriate as any.

I’m having some trouble getting the syntax correct on my .htaccess file…but admittedly I am probably trying to do something funky.

I have several (about 500) files that are indexed well with Google, and they are in the form of:

http://www.domain.com/news.php?action=fullnews&id=10 (the 10 changes with the article number obviously).

I moved all of the pages from the old CMS (phpnews) to Wordpress, and now the new articles (all moved over into the wordpress database) are linked in the form of:

http://www.domain.com/archives/4 (again, the 4 changes w/the article). The original and new numbers are all different, so the old number 134 might match up to it’s new counterpart with number 214, there’s no mathematical difference between the two, so I can’t do something like oldnumber + XX = newnumber.

Anyway, I want to do 301 redirections from the old numbers to the new URLS, but I can’t even get the first one to work, much less making the other 499 entries in what will be a 1,000,000GB file when I’m done, but I figure it’ll be better than loosing a lot of incoming traffic.

Can someone help me with the correct syntax to use in the .htaccess file?

Thank you in advance, hope I have explained the problem correctly.


I came up with a PHP solution instead, thinking you would find it easier to manage.

Should be able to just name it phpnews.php and put in the document root.

$article_list needs to be pairs of article numbers on separate lines. The first number from phpnews and the second from wordpress.<?php $base_uri = 'http://' . $_SERVER['SERVER_NAME'] . '/'; $not_found_uri = $base_uri . 'missing.html'; $message = 'Article does not exist'; $redirect_uri = $not_found_uri; $article_list = <<<ARTICLES 1 2 2 3 3 5 4 7 5 11 6 13 7 17 8 19 9 23 10 29 11 31 ARTICLES; if(preg_match('/id=([0-9]+)/', $_SERVER['QUERY_STRING'], $matches)) { $phpnews_id = $matches[1]; $re = '/^' . $phpnews_id . ' ([0-9]+)/m'; if (preg_match($re, $article_list, $matches)) { $wordpress_id = $matches[1]; $redirect_uri = $base_uri . 'archives/' . $wordpress_id; $message = 'Article has moved to ' . $redirect_uri; } } header('Status: 301 Moved permanently'); header("Location: $redirect_uri"); echo "$message\n"; ?> :cool: openvein.org -//-


Hmmm, I hadn’t thought about that. Thank you, this just might be what I was looking for!