Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-08 15:36:13

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Redirect .htaccess magic

I recently moved a Textpattern site to a new host and a new domain name. There were a variety of problems with the original host, one of them being that clean URLs were disabled because the server was set up to ignore any .htaccess files in the document root, and the server administrator was unwilling to make any changes, and anyway he was providing the hosting service for free.

Since the service was free, the original TXP site is still active, and I cannot use a proper 301 .htaccess directive to redirect all traffic to the new site. Instead, I edited the page template to use the old-school META REFRESH redirect, like so:

<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My title</title>
<meta name="robots" content="noindex"/>
<meta http-equiv="refresh" content="0;url=http://newdomain.tld<txp:page_url type="request_uri" />"/>
<script>
window.top.location = 'http://newdomain.tld<txp:page_url type="request_uri" />';
</script>
</head>
</html>

By grabbing the request_uri, Textpattern intelligently redirects URLs on the old site to the same documents on the new site. Peachy!

Here’s the problem: The old site used ?=messy URLs, so the forwarded request_uris are in messy format. The new site uses clean URLs. Is there any way to rewrite the forwarded URLs to match the clean URL structure of the new site? I’m thinking that there might be some way to do this within the new site’s .htaccess file.

Offline

#2 2011-02-08 16:18:33

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,257
Website GitHub Mastodon Twitter

Re: Redirect .htaccess magic

Hi John

I think that installing zem_redirect might do it for you.

Edit: especially if the article id is included in the url

Last edited by colak (2011-02-08 16:21:07)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2011-02-09 15:48:33

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: Redirect .htaccess magic

Thanks, Colak! I have the plugin, but I’m not sure how to use it. I note that the documentation is for subscribers only, and Zem doesn’t accept new subscribers. Can you tell me the basics?

Offline

#4 2011-02-09 16:58:35

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Redirect .htaccess magic

You might try reading through this thread: http://forum.textpattern.com/viewtopic.php?id=23552

I was one of the original subscribers but, even though I can still log in, I can’t download a copy or access the original documentation.

Offline

#5 2011-02-09 17:31:25

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Redirect .htaccess magic

John,

you can try rah_metas, that has built-in messy-to-clean redirection.

And, if I were you, I’ll go an step beyond.

1) change DNS records for old site to point to the new server.
2) Thus, when someone requests olddomain.tld, the request arrive to the new server.
3) Then, there, in the new server, you could set the oldserver.tld domain as an alias for the newserver.tld domain
4) Finally, by using a simple, common, old school .htaccess trick, you externally rewrite or redirect the requests from oldserver.tld to newserver.tld.
5) rah_metas takes care of the rest (messy to clean redirection).

Some gains: speedier than a META redirect, and you keep the olddomain.tld tied to the new client’s server (so, easier to do any other management task)…

Hope that helps.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2011-02-09 19:53:42

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Redirect .htaccess magic

johnstephens wrote:

I have the plugin, but I’m not sure how to use it. I note that the documentation is for subscribers only, and Zem doesn’t accept new subscribers.

And even old subscribers only had access to the docs for one year (and cannot re-subscribe)…
If I’m not mistaken, when you switch from one permanent link mode to another, just having the plugin installed and activated will redirect the old URLs to the new ones.

Last edited by els (2011-02-09 19:54:01)

Offline

#7 2011-02-10 07:54:21

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: Redirect .htaccess magic

I have the plugin, but I’m not sure how to use it. I note that the documentation is for subscribers only, and Zem doesn’t accept new subscribers.

Yes, it’s frustrating. I wrote down one or two things I found out in this thread and this post and here you can find the download address.


TXP Builders – finely-crafted code, design and txp

Online

#8 2011-02-10 07:55:05

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,257
Website GitHub Mastodon Twitter

Re: Redirect .htaccess magic

johnstephens wrote:

Thanks, Colak! I have the plugin, but I’m not sure how to use it. I note that the documentation is for subscribers only, and Zem doesn’t accept new subscribers. Can you tell me the basics?

Hi John

I have no access to the docs either but (for my install at least), the plugin just redirects all messy urls to the chosen /id/title schema.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#9 2011-02-11 15:08:59

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: Redirect .htaccess magic

colak wrote:

…the plugin just redirects all messy urls to the chosen /id/title schema.

Els wrote:

…just having the plugin installed and activated will redirect the old URLs to the new ones.

Indeed it does! Thank you!

And thanks also to the rest of you for your insights.

@Maniqui: I wish I could follow your recommendations. Trouble is, the old site was hosted on a subdomain of a domain owned and used by the hosting provider, and the host is not inclined to offer any kind of support, whether by altering the DNS records or otherwise.

Offline

Board footer

Powered by FluxBB