Content last modified Monday 6 March 2017
hop to #bottom
About It:
Rate it:
  • Helpful?
  • 0 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

Moving the /textpattern/ folder

Ask yourself these two questions:

  • 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!


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';


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)


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';


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

if ($n) return hu.'textpattern/css.php?n='.$n; return hu.'textpattern/css.php?s='.$s;

Remove the textpattern/ text from it so they both read:

if ($n) return hu.'css.php?n='.$n; return hu.'css.php?s='.$s;


Here you find the line that reads:

gTxt('log_in_at').' '.hu.'/textpattern/index.php';

and change it to:

gTxt('log_in_at').' 'https://YOURSECUREWEBSITE.COM/textpattern/index.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.


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.

Article Request Count:
Posted here:
05 Jun 2005
Article modified:
05 Nov 2006

Comments/questions? Leave a message in the form.

Commenting is closed for this article.

Commented (11)

I’ll look into if this still works for RC4. If not, I’ll update the article.
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.
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 …

Seems to work for 4.0.2.
Seems to work for 4.0.3.

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:

< ?php
include_once '/my/directory/outside/public_html/mysitename_config.php';
? >

(Remove spaces between ? and angle brackets.) Note the directory is an absolute path.
Good angle Lee. It’s never wrong to exclude critical files from outside the webfolder.
Thanks, add to bookmarks…

With the new version, Instead of going to txp/include/txp_admin.php you have to go to txp/lib/txplib_admin.php and change this line in 2 places.

n.n.gTxt(‘log_in_at’).’: ‘https://YOURSECUREWEBSITE/index.php’;

This’ll make sure you’re new user and forget password e-mails will send the correct link.

Would be cool if the /textpattern/ folder could be moved more easily.

Roijason Lagunzad:

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.

That’s a bit complicated problem you have built, Roijason. :-) I would just move Textpattern to work in “blog” folder because that would be the easiest solution… and the only solution I can think of.

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment?

You know you want to visit the Archives.




There are also tag clouds, 'cause those are fun.
Published with Textpattern