Category: web

301 Permanent Moves from a Sub-directory to another server when Redirect from Apache won’t work

20th May 2010 by andyk

I had a problem  the other day where I had to move my server to a new server location…  In my case I was moving the support pages for my WordPress Plugin “Share and Follow” from my Phat-Reaction server to a new server devoted to Share and Follow.

To make it a little more difficult I need to only move a sub-directory to the new server and not the whole domain….  this meant that I was moving
Source: http://phat-reaction.com/share-and-follow/   (and all sub-directory contents)
to
Destination: http://share-and-follow.com/wordpress-plugin/

At the source there were many pages below the /share-and-follow/  subdirectory, all delivered via WordPress on Apache.  In fact the pages used up to 3 levels of sub-directory below this point.

So I tried to use the Apache Redirect command inside both <Directory> and <VirtualServer> tags but to no avail. In fact when I contacted my hosting company they told me point blank that it could not be done with their server and that 301 Redirect’s could not work when going to an external server.  Not sure I believe that, but no matter what I tried I could not make the standard Apache method work.

To make it work I chose to use PHP and header() commands along with a few extra little bits. Here is the process I took to move it all

  1. Changed the URL inside the WordPress settings to the new URL
  2. Made a back up of the Database
  3. Placed the new .htaccess in the sub-directory
  4. Placed the new index.php in  the sub-directory
  5. Deleted all traces of WordPress from the directory and sub-directories

In essence what it does is use Mod-ReWrite to tell the server that all access to the server below the /share-and-follow/ directory should actually load /share-and-follow/index.php.  So it did not matter if it was /share-and-follow/documentation/working-with-themes/  or /share-and-follow/my-stats.html  it would always load the same index.php.  this is all controlled by the .htaccess file.

example .htaccess


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /share-and-follow
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /share-and-follow/index.php [L]
</IfModule>

remember to change the settings to be as you need for your server. For me I was working in the share-and-follow sub-directory. The only lines that need to be changed for your purpose is RewriteBase and RewriteRule. RewriteBase should point at the sub-directory that you want to move, RewriteRule should point at the file you want to automatically load to deal with the redirection.

Once the URL rewrite is in place, all that is left is to configure the php side of things.

example index.php


<?php
/*
 * This file simply redirects with a 301 to a new page with the same name when used in conjunction with a .htaccess
 *
 * @param $stubOld = the Stub URI that will be replaced with the new URL
 * @param $stubNew = the new URI location for the files.
 */

$stubOld = 'http://phat-reaction.com/share-and-follow/';
$stubNew = 'http://share-and-follow.com/wordpress-plugin/';
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
$url = curPageURL();
$url = str_ireplace($stubOld ,'' , $url);

header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$stubNew.$url);
flush();
?>

In this one you only need to change two things. The $stubOld = Old Source URL and $stubNew= New Destination URL. By changing these two items a URL such as http://phat-reaction.com/share-and-follow/documentation becomes http://share-and-follow.com/wordpress-plugin/documentation

And the great part is that Google loves it when you do things this way with a 301 error (Moved Permanently).

Enjoy and share it with your webmaster buddies. Here are the files if you want to download them

Share and Follow wordpress plugin released

9th April 2010 by Phat Reaction

After being fed up with most of the other share and follow link systems I decided to build my own. The issues as I saw it was

  1. Links often went via javascript to a 3rd party like AddThis
  2. No control over if things are in a new window or in the same one
  3. pagerank give away
  4. javascript needed to use the systems on screen from AddThis and others
  5. limited display setup
  6. Only share links and no follow links
  7. all or nothing approach from the majors, all pages or posts or nothing
  8. No widget control, no theme tags, no shortcode


So those were the bits that were missing, so I created a system that dealt with all of those issues and more.  We now have widgetized sharing and following, shortcode availabity, multi-size icons (16, 24, 32, 48, 60 px), follow tab in either the top/bottom/left/right side of the screen, funky text replacement option for follow bar.

Basically it’s got most things going….. and is currently being re-developed with more functions and features for version 2.

take a good look at the share and follow plugin for wordpress

Stage 2 on the cards for Unselfish Designs

10th March 2010 by Phat Reaction

After getting a simple blog to help show off her products Wendy is now ready to take unlsefish designs to the next level with a bunch of new features.

  • T-shirt builder
  • Share links
  • Social networking
  • Sales order processing
  • A change in direction on design and layout

We’re looking forward to all the challenges she can throw at us.

Why I use WordPress for nearly every install I make

27th November 2009 by Phat Reaction

I was feed up with re-doing the same things time and time again

By using wordpress external site I am able to remove a bunch of my standard work like adding content , setting up the head section or configuring my layout areas.  They are now all pre-configured inside my own hand made made theme, and from there on in I just change the CSS and made wordpress theme changes as needed by the client.  Most likely it saves me 5 hours on each install.

And to be honest, I hope the ease of wordpress to use will enable a site to grow quickly, even if it is just a 1 page advert. Possibly the most sucessful wordpress install that I have made so far would be The Commonwealth Conversation external site.  This site has had over 30,000 visitors and 1000 comments anf got to page rank 7 in about 4 months, not many sites can say that.

Should that really be linked to on every page?

24th November 2009 by Phat Reaction

While reading through page rank explained by Ian Rogers, it became clear to me that there are many occasions on a site where links are contesting with each other to become highest.

For example, the footer and the header tend to have more or less the same links in them on every page. Lets just suggest that those were, Jobs, About, logo with link to homepage, Breadcrumb, Privacy statment, contact, sitemap and accessibility information.

For me looking at this list, there are a bunch of links there that really very rarely get accessed. These would be items like Privacy Statment, About, Jobs and Accessibility information. Why not reduce the number of links here, by just having the about link on the page, and the other links located on the about page.

Ok maybe if your company gets lots of people looking looking for jobs… then it would be wise to have another domain such as http://jobs.myCompany.com, get it into webmaster tools from google and let it do the rest.

The main thing being here that you will have reduced contention against your primary pages by a factor of 3 on every page.

Secondly by setting up either the Logo or just the breadcrumb to have the link to the homepage, you will have reduced contention against your catagories.

By choosing to remove the link from the logo, it will mean that accross the site with a common menu that they homepage will not have as many links as the catagories. As on the homepage the breadcrumb is not clickable.