Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Splitting a textpattern site into two - using section redirects
I’m wondering how best to split off some sections of a textpattern site to a copy at a different domain.
I’m thinking I’d first do a complete image copy of the complete site, and then change the config to use the right db and domain. I can also delete the section articles I don’t want on original and new.
I’d then create a page on the old site to be used by all sections I want to redirect.
And also an error redirect for section queries.
Thus for example, section “Sports” would be changed to use a page called ‘sports_redirect’ and this just has something like the following:
<txp:zem_redirect type=“301” to=“http://www.newdomain.com/$_SERVER[‘REQUEST_URI’]” />
Is there a textpattern technique for composing a new URL, i.e. with a different domain, but everything else preserved?
I’d also delete the sections on the old site such that there’d be an error redirect on the 404 page:
<txp:aks_301 start=“s=Sports” url=“http://www.newdomain.com/$_SERVER[‘REQUEST_URI’]” />
Again, this needs to compose the redirected URL from the existing one.
Is this the right approach?
Or is there a far more appropriate way of doing this?
Thanks.
Offline
#2 2011-04-19 21:15:41
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Splitting a textpattern site into two - using section redirects
Wouldn’t a couple of redirect rules in .htaccess be simpler?
Redirect permanent /section-name http://www.newdomain.com/section-name
Offline
Re: Splitting a textpattern site into two - using section redirects
Hi Crosbie,
I’m wondering how best to split off some sections of a textpattern site to a copy at a different domain.
I’m thinking I’d first do a complete image copy of the complete site, and then change the config to use the right db and domain. I can also delete the section articles I don’t want on original and new
An alternative approach to solve this is to serve a section on the one (current) domain as the root of the other (new) domain.
The advantage is that you can continue administering the new website using the same TXP install. Or, in other words, you manage the content for two websites from the same TXP install (note: this is not the same as the new “multi-site” capabilities offered since TXP 4.2.0).
The technical way to do this is setting up a reverse proxy (via PHP or Apache, for example).
Thus, requests to http://www.newdomain.com will end up serving pages from http://www.olddomain.com/some-section/ and http://www.olddomain.com/some-section/some-article.
Regarding your suggested approaches, I don’t think you will be able to use server variables directly inside TXP tags.
You may want to convert the server variable into a TXP variable, like:
<txp:variable name="request_uri"><txp:php>echo $_SERVER['REQUEST_URI'];</txp:php></txp:variable>
Which then, you could use like this:
<txp:aks_301 start="s=Sports" url='http://www.newdomain.com/<txp:variable name="request_uri" />' />
(Notice the single quotes wrapping the value for url
attribute, which enable the parse of txp tags nested inside other txp tags attributes)
Also, as Els suggests, some redirects directly put in .htaccess may be an easier way to solve this.
Is there a textpattern technique for composing a new URL, i.e. with a different domain, but everything else preserved?
For articles belonging to this certain sections you are moving, you could try something like the following (really simplified) example:
<txp:article>
<txp:if_article_section name="sports">
<a href="http://www.newdomain.com/<txp:permlink />"><txp:title /></a>
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_section>
</txp:article>
Hope this helps.
PS: big fan of your articles at DigitalProductions.co.uk here :)
Offline
Re: Splitting a textpattern site into two - using section redirects
Els wrote:
Wouldn’t a couple of redirect rules in .htaccess be simpler?
Yup, but I still need to redirect URLs that just specify the article ID, i.e. http://olddomain.com/index.php?id=123
If that article #123 is in section X then I think I need to make the page for that section into a redirect.
maniqui wrote:
An alternative approach to solve this is to serve a section on the one (current) domain as the root of the other (new) domain.
The advantage is that you can continue administering the new website using the same TXP install. Or, in other words, you manage the content for two websites from the same TXP install (note: this is not the same as the new “multi-site” capabilities offered since TXP 4.2.0).
Sounds attractively elegant, but I still need requests to olddomain.com/page in some-section to be 301ed to newdomain.com/page in some-section.
Reverse proxy seems a bit of a headache compared with a clean break where the site is forked into two separately managed sites (even if multi-site)
Regarding your suggested approaches, I don’t think you will be able to use server variables directly inside TXP tags.
Yeah, it was just to indicate the sort of thing I wanted. I was hoping someone would point out the correct method, whether <txp:url/> or <joe_plugin:url/>.
You may want to convert the server variable into a TXP variable, like:
Yeah, that’s what I’d have resorted to. I was hoping there was something more elegant.
(Notice the single quotes wrapping the value for
url
attribute, which enable the parse of txp tags nested inside other txp tags attributes)
Useful tip, thanks!
For articles belonging to this certain sections you are moving, you could try something like the following (really simplified) example:
<txp:article>
<txp:if_article_section name="sports">
<a href="http://www.newdomain.com/<txp:permlink />"><txp:title /></a>
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_section>
</txp:article>
I don’t understand what <txp:article><a href=“http://neworolddomain.com”>title</a></txp:article> is supposed to achieve? Does it cause the display of the article at that url using a default form, or what?
Using a 301 redirect plugin such as <txp:zem_redirect> on a dedicated redirect page for a particular section seems to be more effective to me.
Hope this helps.
Yes, quite helpful thanks. It also helps let me know that this isn’t a FAQ and/or doesn’t have a simple solution.
PS: big fan of your articles at DigitalProductions.co.uk here :)
I get little feedback, so yours is much appreciated. Ta. :)
I’m intending to split DP off into culturalliberty.org/blog so all the respective articles end up there, leaving DP dedicated to blogging about project development work, e.g. 1p2u.com & contingencymarket.com – both of which I will release as free software and document, in case others are interested in helping develop them further.
Last edited by crosbie (2011-04-20 09:43:01)
Offline
Re: Splitting a textpattern site into two - using section redirects
This seems to do the job for the redirect page:
<txp:variable name="request_uri"><txp:php>echo $_SERVER['REQUEST_URI'];</txp:php></txp:variable>
<txp:zem_redirect type="301" to='http://www.culturalliberty.org/blog<txp:variable name="request_uri" />' />
Offline
Re: Splitting a textpattern site into two - using section redirects
For each section to migrate away, e.g. ‘Sport’:
1) Create new section, e.g. OldSport – non-searchable, non-syndicatable, etc.
2) This new section uses a redirect page:
<txp:variable name="request_uri"><txp:php>echo $_SERVER['REQUEST_URI'];</txp:php></txp:variable>
<txp:zem_redirect type="301" to='http://www.MYNEWDOMAIN.com<txp:variable name="request_uri" />' />
3) Change section of all articles in Sport to OldSport
4) Create redirect for when section request for Sport fails (in error_default page):
<txp:variable name="tonewdomain"><txp:php>echo 'http://www.MYNEWDOMAIN.com'.$_SERVER['REQUEST_URI'];</txp:php></txp:variable>
<txp:aks_301 start="s=Sport" url='<txp:variable name="tonewdomain" />' />
5) Because one can’t seem to delete sections, rename section Sport to WasSport – also making it non-searchable, non-syndicatable, etc.
6) It seems there’s not much to do about comments. They’ll redirect.
So, if you want to see it in practice:
Here’s a link to an article on the old site that redirects: http://www.digitalproductions.co.uk/index.php?id=258
And here’s one that doesn’t redirect: http://www.digitalproductions.co.uk/index.php?id=142
Here’s a link to a list of articles in section ‘Natural-IP’ category ‘personal data’ that redirects: http://www.digitalproductions.co.uk/index.php?s=Natural-IP&c=personal-data
Here’s one that doesn’t redirect: http://www.digitalproductions.co.uk/index.php?s=Information&c=about
Of course, I’ll probably find out soon that this split was a really bad idea…
Offline