Textpattern tips, tutorials and code snippets

Redirect /textpattern to /admin for multi-site installs

Since version 4.2.0, TXP supports multi-site installations from one TXP installation (all sites share the same TXP files, but are installed into different databases, and have their own admin and public folders).

In these kind of installations, the TXP admin side is moved from www.example.com/textpattern to www.example.com/admin (and there is also the option to move it to admin.example.com).

This minor change can break some TXP plugins that are still referencing stuff in /textpattern folder.

Possible fix

One possible fix could be to edit the plugins and change every reference of /textpattern to /admin. But, in the end, this will become a maintenance nightmare, as whenever a new version of the plugin is installed you mayhave to do it all over again.

Another possible fix could be to wait until the plugin author makes this change for us. But that may take time, or the plugin might be abandoned so the change won’t ever take place in an official release.

Using mod_rewrite

And then, there is this fix, that worked flawlessly for me in a few TXP installs.
It’s a simple change that implies adding a line to the .htaccess file on the root of your TXP website. In the case of a multi-site installation, the .htaccess file is located in the /public folder.

So, there, in that .htaccess file, you should add the next line above the <IfModule mod_rewrite.c> line:

Redirect 301 /textpattern /admin

That should be enough to fix most (if not all) TXP plugins, even those that use JS and CSS assets.

Finally, a last note: this fix doesn’t cover the case of using admin.example.com for your TXP admin side. I have yet to try that kind of install and figure out which will be, in that case, the best fix for the issue.

If you are in that situation and can’t wait for me to fix it, I suggest you to do a search for “redirect folder to subdomain”. You will probably find the solution in no time. Then come back here and share it in the comments. Or better yet, write a new TXP Tip!

3 Comments Comment feed

Finally, a last note: this fix doesn’t cover the case of using admin.example.com for your TXP admin side. I have yet to try that kind of install and figure out which will be, in that case, the best fix for the issue.

I guess quite simple as your way:

Redirect 301 /textpattern http://admin.blabla.ext/

mod_alias on Apache webservers is needed.

Patrick,

it should be

Redirect 301 /textpattern http://admin.blabla.ext

without the trailing slash – otherwise I had issues with Twitter’s oauth.

Once small correction:

The Apache Redirect statement uses mod_alias rather than mod_rewrite. Some hosts do not allow mod_rewrite but mode_alias is a base module so Redirect should work even if mod_rewrite is not allowed.

Of course, because it isn’t using mod_rewrite, it is correct to place it outside of the <IfModule mod_rewrite.c> section (if present).

Some other webservers than Apache also provide simple redirect facilities (or even more powerful mod_rewrite-like ones) so this redirect mechanism should not be limited to Apache servers — only the implementation would differ.

Add a comment

Use Textile help to style your comments