How do I setup htaccess for 301 redirects, post Joomla to WordPress migration?

I’ve almost completed the tedious task of migrating a relatively complex Joomla site over to WordPress.

The (more or less) final stage I am wishing to figure out is the 301 redirections. I’ve spent the past few hours researching this topic, but I’ve not found any tips specific to my situation (particular the sub-directory structure). I’d greatly appreciate some hand-holding. I don’t wish to mess this up because I realise it could impact the hundreds of incoming links from search engines.

Read More

Here’s the background information:

  • Joomla was installed in www.domain.com/site/

  • WordPress has been installed in domain.com/wordpress/

  • All Joomla articles were migrated to WordPress installation, and post IDs were maintained.

  • Joomla URI permalink structure for articles is: www.domain.com/site/YYYYMMDD###/...

    e.g. www.domain.com/site/20110623398/articles/category-slug/article-slug.html

    The ### is the unique ID of the article on Joomla (aka post ID).

  • The posts in WordPress have the same unique ID. Thus www.domain.com/site/20110623398/articles/category-slug/article-slug.html can be redirected to domain.com/?p=398

  • There are a few other URI structures I’ll need to handle. But I will address that once I have the redirection of the articles figured out.

MY QUESTION (IN PARTS)

  1. How do I set up the .htaccess file so that all incoming links to joomla articles have the unique ID extracted and then redirect to /?p=UID (as a 301 redirect)?

  2. How do I do this in such a way that the site will always use or display domain.com/ as the home directory (with and without the www), whilst keeping the site located in /wordpress (or in /site, if that works better for the redirects – which I suspect it will).

    I don’t, however, want the site to ever load up and show a /wordpress/post-name-etc/ type URI (or /site/post-name-etc/ URI). Meaning I want the /wordpress/ or /site/ part to always be removed from the end user point of view (including search engines).

    I believe the .htaccess file is also used for this.

  3. Along with many other sites and posts, I have read the info related to Giving WordPress It’s Own Directory on the WordPress Codex.

    Point #4 on that article says, “Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address).”, but I have a .htaccess file in the root already, and it has lots of code in it.

    Is it okay to just copy the index.php and not the WP htaccess file?


Points (2), combined with (1), is where I came a bit unstuck. Getting all the articles on domain.com/site/ to redirect to domain.com/, and for the correct page to come in from domain.com/wordpress without displaying the /wordpress/ part.

As mentioned above, I suspect it may be best if I move the wordpress site to domain.com/site (and change it’s configuration file home directory settings accordingly).

Related posts

Leave a Reply