01239 841259

Moving Wordpress Directories

When I installed wordpress on Poppit Sands site it was as a bit of an experiment and I used the default location of domainname/wp I loved wordpress and decided to go with it for the site after adding a fair bit of content.

I never did quiet like the /wp in all the URL’s and this evening I decided to do something about it.  I started off by just changing the settings -> general to www.poppit-sands.co.uk

New Settings

With that done, I moved  all the files in the root directory of my website to a new folder  (with the exception of the /wp directrory and any other files you wish to keep there.  You want to keep .htaccess).  After that I moved all the files and folders in the /wp directory into the root directory.   So far so good.  My website is back, but still slightly broken.  Images have a hard coded reference to their original location.  I manually updated the theme’s header image location by re-uploading the jpg.

So I currently have broken images and any old external references (and the juicy pagerank) will be all pointing to a nice 404 page not found entry.  SO the clever bit and probably the only but worth reading is this.

You have a small file in the root directory of .htacess or at least you should.  If you moved it earlier then put it back !  This files has amoungst other things rules to re-direct webpage requests to something / somewhere else.  This is a very powerful little file.

Anyway ours is a simple requirement.  Any requests for any content with WP in the name need translating to the same address without WP.  Telling the web browser and google that this is a permanent move (code – 301) means page rank and search engine listings will migrate over time.

SO the magic line to insert is

RedirectMatch 301 ^/wp/(.*) http://www.poppit-sands.co.uk/$1

You should already have entries in there, put it towards the top before any other clever stuff you may have.  Save the file and you are done.   Now all the images still link to an address with WP in them but they do resolve correctly and the site works.  I will probably go back thru old posts and edit in html to remove the wp  from the path.  BUt no rush.

It should take about 20 mins to do max…. but make sure you back everything up first…. and know how to put it back !!