Need help with 301 Redirect

propsta

Registered Member
Joined
Oct 29, 2009
Messages
52
Reaction score
17
I run a decent gaming site that was running a CMS from 1996 (Custom). I recently migrated the entire site to Wordpress. The thing is I do not have a clue how to write the 301 redirect in the htaccess. Can some one help me.

The site is http://www.mygamer.com/

Some examples of 301s we need:

http://www.mygamer.com/index.php?page=globalnews

to:

http://www.mygamer.com/mgwp/category/news/

Remember the new WP site will be moved to root, so that subdir mgwp will be gone.

http://www.mygamer.com/index.php?page=portal2&platform=&genre=&platform2=reviews

to:

http://www.mygamer.com/mgwp/category/reviews/

There are a few categories I would need to do 301's with news, reviews, interviews, previews, articles. Id also need all content 301'ed.. LIke:

Review:

http://www.mygamer.com/index.php?page=gameportal&mode=reviews&id=556278

to:

http://www.mygamer.com/mgwp/staying-out-of-reach/

Please can anyone help?
 
Last edited:
You can do this by manually editing the .htaccess file at the top level of your <VirtualHost> DocumentRoot directory. Apache comes with a "RedirectPermanent" directive that does exactly what you need.

Code:
RedirectPermanent /blog/my-old-article-name.html /blog/2013/my-new-article-slug

Be sure to place this *above* any stuff automatically added by Wordpress.

e.g.

Code:
RedirectPermanent /index.php?page=globalnews /category/news/
 
Thanks man. I appreciate it. Is there anyway to automate this? I have over 60k articles, I dont think I could do that with all.
 
Thanks man. I appreciate it. Is there anyway to automate this? I have over 60k articles, I dont think I could do that with all.

I'm afraid it's only possible by writing some kind of script (PHP, Python, Ruby, etc.) that would do the job for you. I don't know how your database is organized, but you would need to match an article from your old database to an article in the WP database. Not really a hard task for an experienced programmer, but you seem to have not enough experience...

Another possible solution is to redirect all traffic that matches "&id=%articleId%" pattern and then redirect it using a custom-made php-script... But either ways, you'll have to code some script.
 
visit the site below
Code:
http://corz.org/serv/tricks/htaccess.php
It has pretty much everything explained on htaccess. What I would do is take the something from page=something and replace it with /categories/something
Just make sure that the new urls are named according to the old urls and I think you'll be redirect most of the urls...
 
Back
Top