Moving the /textpattern/ folder

Have you ever had the urge to move the textpattern directory somewhere else and use it as a section instead?

Do you have a site that you want some tightened security and therefore keep the admin part of TXP on the encrypted secure https server?

Did you anser yes to any of the questions? Great, then keep on reading.

Needed note

First off, I have to warn anyone who does this that every time you update TXP you will need to do these changes on all the files.

Also, the example that follows is written about how to move the textpattern folder to a secure part of the webserver, rather than writing two examples, but hopefully you will get the idea and be able to implement it if you only wish to rename the folder to a different name.

Anything that is written in CAPS means you need to change it to the appropriate path on your webserver.

And the last thing being that this hack has only been tested on Textpattern RC3, so it might work differently in later revisions and release candidates.

The files

So let’s get started and see what files you need to keep an eye out for. The files we are going to edit are the following:

index.php

textpattern/config.php

textpattern/css.php

textpattern/publish/taghandlers.php

textpattern/include/txp_admin.php

Moving the files

Start off by copying everything contained in the textpattern folder from your original textpattern folder to the secure one. Also move the textpattern/css.php file to the root folder of your normal textpattern site.

Done? Well let’s get started with the editing then!

index.php

First and foremost, we start by opening up index.php and find the line that states:

include './textpattern/config.php';

Change it to read:

include '/ROOT/PATH/TO/YOUR/SECURE/WEBSITE/textpattern/config.php';

As an example, if you are on a standard Apache install this would look something like:

include '/home/henrik/www-secure/textpattern/config.php';

textpattern/config.php

This file is now located in your secure textpattern folder, so open it there and find the line:

$txpcfg['txpath'] = '/OLD/ROOT/textpattern';

Change it to read:

include '/ROOT/PATH/TO/YOUR/SECURE/WEBSITE/textpattern';

(see above for example)

textpattern/css.php

This has been moved to your root folder of your normal textpattern site, so open that one and change the line:

include 'textpattern/config.php';

to (yes, you guessed it allready):

include '/ROOT/PATH/TO/YOUR/SECURE/WEBSITE/textpattern/config.php';

textpattern/publish/taghandlers.php

This file is, of course, the one in your secure textpattern folder, and the two lines to find are the following:

textpattern/include/txp_admin.php

This changes the e-mail sent when you register people for using the admin interface; if you are the only user you could skip this one.

Done? Already?

Not really, we have to tidy up a bit first. Remove the textpattern folder from your normal textpattern folder and prepare yourself to do a drumroll since the excitement will be immense to see if it works, which it of course does.

So there you have it: how to move the textpattern folder to a secure folder on your webserver in some pretty simple steps.

Updating

A setback with this, of course, is that when you update you have to unpack/subvert to the non-secure folder and do any login to the admin interface and run any update, then redo these steps from scratch again.

Commented (11)

In RC5, I suspect an alternative to moving ‘css.php’ to the root folder would be to skip the steps which modify ‘textpattern/publish/taghandlers.php’ and ‘textpattern/include/txp_admin.php’ and instead find the ‘siteurl’ entry in table ’[prefix]txp_prefs’ in your database and change it from “www.YOUROLDSITE.COM/” to
“www.YOURSECUREWEBSITE.COM/” or “www.YOUROLDSITE.COM/new_directory/”, depending on where you are moving things to.

If you do this, you should be able to move ‘css.php’ naturally along with the rest of the files. Also, there is no need to edit the two php files I’ve just mentioned.

I used this technique while moving my textpattern directory to another on the same host. I cannot guarantee that it will be appropriate for a cross-server move, but I imagine it would.

Jason,
The reason why I move the css.php file outside my textpattern folder is to beef up security since otherwise you can locate it by just checking the code where it snags the css.php file from. But ofcourse, this is not needed …

For increased security, I moved my config.php outside my public HTML directory, and called it mysitename_config.php. (No need to rename if you only have one TXP site.) Then I made a new config.php with the following:

Hi, i installed my textpattern in a folder called “admin” in root directory, it’s my secure folder, now i what to show my articles on “blog” folder which is also in root folder, i’m getting confused now lol.