This post discusses how using .htaccess on Apache will actually help you avoid many 404s and also support multiple permalink structures in the process.
.htaccess is very finicky and that in there lies the problem, but with this article, you should be able to solve a few problems (and even do some extreme customization).
My issue was the following:
I monitor my 404 errors on my blog constantly. This is important as a 404 error basically reports the content is not found. This can be due to a multitude of issue. It’s not uncommon to get 1-5% of your errors as 404 errrors. Anything more than that and the search engines penalize you.
So here’s where I looked at it. In a typical wordpress installation, people have a tendency to occasionally change their permalinks with no idea what the repercussions are.
So here’s where it gets interesting. Changing your permalink structure immediately breaks any links to your web content anyone has linked to in the past.
You would think that WordPress would support multiple permalink structures, but it’s not high on their list today. So how do you support your old links and still serve up that same content using your new link structure, thus avoiding 404 errors?
The answer? If you’re running Apache is a beautiful tool called mod_rewrite. I will say that mod_rewrite is extremely finicky and very hard to deal with. As for the irc support channel, all I can say is it wasn’t a good experience. If I can read the documentation and rarely make heads or tails of certain key components of it, there’s an issue.
So after much muddling around and experimentation and testing, I’ve come up with the solution.
So.. I’ll make it simple for you.
I will list the lines you need to put into your .htaccess file (to change your wordpress configuration to support multiple permalink structures.
It will save you. If you’re using a host, call them up and ask them if they have mod_rewrite activated and available for your use.
If so, then all you have to do is modify your .htaccess file and you’ll be fine.
Here’s what I have in mine:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://swimminginthought.com/$3 # This gives you the ability to support the 4-digit-year/2 digit month/post-name permalink structure.
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://swimminginthought.com/$4 # This covers the 4-digit/2-digit-month/2-digit-day/postname
#Percy
# This ruleset removes the /none from the back of the URL. I had to do this due to a social network’s bad programming.
RewriteBase /
RewriteCond %{REQUEST_URI} none$
RewriteRule ^(.*)/none$ $1 [R=301,L]
#The following stanza below sets my permalink structure to: http://swimminginthought.com/post-name
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I sincerely hope this helps you all. Please remember to comment or link to this page if you like it. Most importantly, if you find it important, consider donating. It makes a difference.