Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-07 22:48:43

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

Need some help with regular expressions... again...

I’m trying to redirect requests for individual articles in a section to the section home page. This is the closest I get:

RedirectMatch 301 ^/section-name/(.+) http://site.com/section-name/?

but it gives me a 404 with a Firefox message saying something about a never ending redirection (it’s in Dutch, I don’t know what would have been the exact message in English). It doesn’t work without the last ? either.

Help please? Is it even possible?

Edit: I can do it with normal redirects, but this section has over 100 articles, so my .htaccess would become a complete novel…

Last edited by els (2008-01-07 23:30:05)

Offline

#2 2008-01-08 00:00:57

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: Need some help with regular expressions... again...

http://site.com/section-name/? would be caught by ^/section-name/(.+)

I haven’t done much with mod_rewrite, so that is all the help I can provide.

Offline

#3 2008-01-08 03:19:35

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Need some help with regular expressions... again...

Make sure this goes above your Txp rewrite rules:

RewriteRule ^section-name/(.+)$ http://site.com/section-name [L,R=301]

Offline

#4 2008-01-08 15:44:27

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

Re: Need some help with regular expressions... again...

Thank you Mary, that works! I think I tried this one yesterday, but I put it after the TXP rewrite rules. (When oh when am I going to understand this…)

Offline

#5 2008-01-10 05:34:47

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Need some help with regular expressions... again...

mod_rewrite process the rules in the order they appear in your .htaccess, so you want any kind of redirects to be processed first, and the L flag ensures it is also the last rule processed.

Offline

Board footer

Powered by FluxBB