Recently, I had noticed lots of 404 error generated by my wordpress software. My old wordpress tag structure changed from:
/tips/tag/linux_software
/tips/tag/one_two_foo
To:
/tips/tag/linux-software
/tips/tag/one-two-foo
As a result lots of error 404 was dumped into my log file. I wrote a small php code to get rid of the problem:
My tag301.php:
<?php $newTagUrl='http://www.cyberciti.biz/tips/tag/'.str_replace('_', '-', $_GET['r']); @include_once("../include.genlib.php"); movePage(301, $newTagUrl); ?>
Finally, I updated my mod_rewrite (lighttpd rewrite engine) to redirect to new location:
"^/tips/tag/(.*_.*)+$" => "/tag301.php?r=$1"
Code for movePage() is here.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 2 comments… read them below or add one }
A WordPress plugin that replies a 301 permanent redirect, if requested URI is different from entry’s (or archive’s) permalink. It is used to ensure that there is only one URL associated with each blog entry.
Nice info… bookmarked – just incase I think of changing URL structure :-)