How to Cloak links on a WordPress Multisite

I spent the weekend installing a few subdomains, by installing WordPress 3 Multisite Network.  I will admit this isn’t for those who are new to WordPress but I did learn a lot from the experience.  Now before you go start to install a Multisite, you should understand that when WordPress creates more sites these are virtual spaces on a virtual server.   In other words there is no real directory for these sites or sub-directory.  So you will have to consider about how you will insert the htacess code for each domain.   This is where it get tricky.   After you’ve set up your domains or sub-domains you will have a Super Admin Panel.  What I failed to realize is that for some strange reason my main domain lost the [WWW] from my domain.

How did I fix all my Links to the New Domain Format??

I must admit I was glad to find a Tutorial on how to search and replace in a SQL database.   The Author is Lorelle VanFossen and he talks about how to do search and replace anything in content posts. With this tutorial I was able to go through my whole blog and remove any [www] reference from any and all my content.  I must agree with the him on this point, before you even consider using this you should make a complete backup of your SQL Database.  The nice thing about this is that since my images were broke because of the [www] reference, no one could see any images.   So I use that tutorial on all my sites that had the [www] reference and any post broken was fixed.   If your unsure, I would have an expert do this stuff for you.   That way you know it is done right.   Now if your are wanting to update the databases for each site you will need to understand that after you get done installing the new sites each database will have a number like “wp_#_posts” and so on, so if you will need to know this so you know which blog you want to.   Whiich it starts of with “wp_posts” for your main site and any extra multisites start off with one and goes up.

Why Can’t I cloak my links??

Basically now since you have more than one site and those sites are virtual there is no way for you to physically edit those htacess websites.   I even tried to use WP Htacess Control plugin to see if I could get it to work that way, but that didn’t work.   I even emailed the author of the Link Cloaking Pluging, and he said:

The free version of the cloaker plugin doesn’t support Multi Site installs. This is because it relies on .htaccess modification, and its .htaccess rules are no suited for multisite. The paid version should work, however.

Janis Elsts

I really can’t complain about this because I know he/she wants to make money just like the rest of us struggling blogger, but I believe that if you are going to offer it for free, you should support it for all WordPress platforms.   So I knew there was a way to still use that link cloaking plug-in.   Although she is right it relies heavily on that .htaccess.   I knew there had to be a work around and I found it on WPMU Development Blog, there they showed you how to use this plugin to cloak all your links.

# Link Cloaker Plugin BEGIN

RewriteEngine On
RewriteRule ^[link prefix]/([^/]*)/([0-9]+)/([0-9]+)/?$ http://[insert site]/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
RewriteRule ^[link prefix]/([^/]+)[/]?$ http://[insert site]/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?name=$1&cloaked_url=$0 [L]

# Link Cloaker Plugin ENDS

You will need to edit it to your website but once you have and install it on your main Htaccess site, the one where th wordpress is installed in.   I will tell you have a 2 other domains, so I had to edit and install it 3 times on my htaccess to get it to work fully.  You will need to:

Settings > Link Cloaking

If your like me and installed Subdomains then you will need to change each link prefix to something different so it can know which website it came from.   I suggest you use go1 and use numbers just like I did.   I am unsure if you will need to do this for your sites that have “/blog1” and “/blog2” and so on.   You will probably have to do this if your are using these as sub-directories but one way you will know for sure is to test it out.   You will need to edit the htacess with the new link and the site you are using that link.   For example, I am using the Prefix [go2] with my and I put those two into the code.   I used [go1] for my and copied the whole code again and edited accordingly.   So I have three different “# Link Cloaker Plugin BEGIN” and three different “# Link Cloaker Plugin ENDS” for each website that I either made or have control over. After all this, I am rather pleased that I have found this information. I do hope I have helped others with this little problem and ask that if I helped you to consider buying something from Amazon to show your support. If you have any questions please feel free to email me, I will be happy to try to answer them.

Have a Good Monday, See you Wednesday!!


Leave a Reply

Your email address will not be published. Required fields are marked *