Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-01-17 12:49:03

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

[solved] redirect 301 throws 500

In the new imca site I have 2 articles which are live but I only want them to appear on their sections and the search results.

The problem is with the search results where the articles appear with their urls. What I am trying to do is to rewrite their individual urls to the section ones.

I have tried

#RewriteEngine On
#RewriteRule ^/about/about-the-imca$ /about/
#RewriteRule ^/workshops/workshops$ /workshops/

which did not work

and

#Redirect 301 /about/about-the-imca /about/
#Redirect 301 /workshops/workshops /workshops/

which returns a 500 error

Does anyone know how to do this?

Last edited by colak (2011-01-17 17:21:32)


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

Offline

#2 2011-01-17 16:05:45

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: [solved] redirect 301 throws 500

The trick/workaround is to do the forced redirect when the individual article is called

I used this code for this article

Edit: I assume that your section landing page is a list.

<txp:if_individual_article>
 <notextile>
  <txp:php>
   txp_status_header('301 Moved Permanently');
   header('Location: http://sankt-georg.info/artikel/777/strassenfest-lange-reihe-bunte-lange-reihe-hamburg-st.-georg ');
   exit;
  </txp:php>
 </notextile>
</txp:if_individual_article>

Edit II.: Oh man, reading the old thread reminds me of the headache (& time consumption) I had when I tried to solve that redirect issue. Maybe you should read the thread too and thank wet on knees for the laconic help he has to offer from time to time :)

Last edited by merz1 (2011-01-17 16:22:10)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#3 2011-01-17 17:21:15

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

Re: [solved] redirect 301 throws 500

That did it! I honestly don’t remember that thread. Thanks sooo much Markus. And kudos goes to Robert for the code of course:)


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

Offline

#4 2011-01-18 12:28:54

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: [solved] redirect 301 throws 500

I also had to search for the solution. Luckily I bookmarked the link as a tip inside my own site :)

Maybe you find the time to write a TXP wiki FAQ entry?


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#5 2011-01-18 13:42:06

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

Re: [solved] redirect 301 throws 500

Hi markus

although i’m yet to contribute to the wiki, this might be a good opportunity to do so.


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

Offline

#6 2011-01-18 14:38:10

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: [solved] redirect 301 throws 500

Good that your problem is solved. But I notice a possible syntax issue in your .htaccess.
I would I have tried

#RewriteEngine On
#RewriteRule ^about\/about-the-imca$ /about/
#RewriteRule ^workshops\/workshops$ /workshops/

(without / after ^, and with \ to escape remaining /)

Offline

#7 2011-01-18 15:09:35

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

Re: [solved] redirect 301 throws 500

Hi Claire

The php method works but I thought i’ll try your suggestion anyway and although it does not return a 500 it does not seem to work either

also tried

RewriteEngine On
RewriteRule ^\/about\/about-the-imca$ /about/
RewriteRule ^\/workshops\/workshops$ /workshops/

again with the same non results.


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

Offline

#8 2011-01-18 20:19:07

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

Re: [solved] redirect 301 throws 500

Hi Yiannis,

Claire’s suggestion seems correct to me, particularly the one about not using / after the beginning (^) of the line. I’ve read that several times in .htaccess documentation and tutorials.
Regarding escaping other / in the pattern, it may help, but definitely it’s not required, as I’ve several un-escaped / on my rewrite rules.

Finally, I’ll appreciate if you could try this version, to see if it works.

RewriteEngine On
RewriteRule ^about/about-the-imca$ /about/ [R=301,L]
RewriteRule ^workshops/workshops$ /workshops/  [R=301,L]

The [R=301,L] flags are required for external rewrites (aka redirects). If not, I understand that you are just doing an internal rewrite.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#9 2011-01-19 06:21:31

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

Re: [solved] redirect 301 throws 500

Hi Julián

your suggestion works:)


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

Offline

#10 2011-01-19 23:09:31

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: [solved] redirect 301 throws 500

The flags … of course … I’m so sorry.
Thanks Julián.

Offline

Board footer

Powered by FluxBB