Multiple WordPress Blogs, GoDaddy Hosting, and .htaccess 301 Redirect

Wordpress Schwag

Regular Left Call readers, please indulge a tech geek for just a moment.

I’d like to share a problem (and offer the solution) to an issue I recently faced after changing the WordPress permalink structure on a blog hosted on GoDaddy. The blog is hosted at the root level of GoDaddy’s Linux Web Hosting and they allow you to create multiple websites on one hosting account. The first website/domain is the “primary” site and it is located at the root level. All subsequent websites/domains are located in subdirectories.

In this case, there is one secondary blog hosted in a subdirectory. The primary website will be referred to as website1.com and the secondary website (located in the subdirectory) will be referred to as website2.com. Both blogs run WordPress and the primary blog (website1.com) is the one that had its permalink structure changed.

The Change

I changed the permalink structure on the root level WordPress blog on GoDaddy from

/year/month/day/postname/

to simply

/postname/

To make sure incoming links as well as Google and other search engines are able to find the blog posts I added the following 301 redirect to the .htaccess file at the root level:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://website1.com/$4

The line above was located at the top of the .htaccess file, but I also tried locating it just below this line:

RewriteBase /

After I put the RedirectMatch line in place (in either location) the old article links redirected properly to their new permalink structure.

The Problem

The problem I met was with the secondary blog (website2.com). The RedirectMatch line was not only redirecting the primary (root level) WordPress blog, but also the secondary (subdirectory) blog. So anytime a visitor attempted to read a post on website2.com it would redirect to website1.com. Needless to say this was a big problem since these are two distinct websites!

The Solution

Turns out there is more than one way to skin a cat. This is the 301 redirect you need to use with GoDaddy Linux Hosting if you face this specific WordPress permalink problem when hosting multiple blogs:

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]

The above line should be placed just after this line:

RewriteBase /

This solution is for the specific problem outlined above, including the specific permalink structure change. If your permalink structure change is not the same, you will need to modify the RewriteRule line accordingly.

There might be another way to resolve this issue, but this solution worked for me for the situation I explained above. If you have any alternate solutions, don’t hesitate to comment. / photo by Armando Torrealba

Tweet about this on TwitterShare on FacebookShare on Google+Share on RedditPin on PinterestShare on TumblrDigg thisShare on StumbleUponShare on LinkedInEmail this to someone

Technology

#GoDaddy#htaccess#permalink#redirect#website#WordPress