Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-07 18:24:36

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

help with a RewriteRule

Hi,
I’m trying to rewrite an old subfolder to a new one:
So, I’ve tried the following rewrite rule (taken from the examples on stupid htaccess tricks):

RewriteRule ^(.*)/vintage-collection/(.*)$ $1/vintage/$2 [L,R=301]

But the rewritten url looks like this:

http://www.domain.com/home/user/domains/domain.com/html/electric-guitars/vintage/62-fender-jazzmaster

The server path to the folder is being appended to the rewritten url :(
I’ve tried setting the RewriteBase to that folder path, but no luck.

Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#2 2008-11-07 18:39:23

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

Re: help with a RewriteRule

If it’s only a matter of redirecting from one subfolder to another, wouldn’t this be enough?

Redirect permanent /vintage-collection http://site.com/vintage

Offline

#3 2008-11-07 18:52:14

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

Re: help with a RewriteRule

Hi Els,

I’m using gbp_permanent_link, so the chunk of the URL that I want to rewrite corresponds to a “subfolder” (a category, a “subsection”).

The URL is:
http://www.domain.com/section/category/title

I just want to rewrite the “category” chunk.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2008-11-07 19:11:02

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

Re: help with a RewriteRule

Ah I see. Can’t help you then, I’m not good with regular expressions :( But wouldn’t gbp_permanent_links be able to do that?

Offline

#5 2008-11-07 19:17:07

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

Re: help with a RewriteRule

Thanks anyway, Els. I’m not good with regex either, although I’ve had a regex class this week on a Python course I’m taking.

But you are right… maybe it can be done directly from gbp_permanent_link.
In the meanwhile, if someone out there knows the answer… keep posting :D


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-11-08 11:05:45

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: help with a RewriteRule

Wouldn’t this work?

RewriteRule ^/(.*)/vintage-collection/(.*)$ http://site.com/$1/vintage/$2 [L,R=301]

Offline

#7 2008-11-08 13:21:54

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

Re: help with a RewriteRule

That didn’t work either.
In this case, no rewrite at all is being done. The URL stays the same and I must admit that I’m now confused about how this works.

Thanks anyway, ruud.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2008-11-08 23:10:56

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: help with a RewriteRule

I’m kind of clueless when it comes to this stuff, but what about…

RedirectMatch 301 /section/cat-old(.*) http://domain.tld/section/cat-new$1

Ed. oops, added wildcard.

Last edited by Destry (2008-11-08 23:14:14)

Offline

#9 2008-11-09 15:13:47

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

Re: help with a RewriteRule

Thanks, Destry.
That worked like a charm. :D

This are the two rules I used finally:

RedirectMatch 301 /(.*)/vintage-collection/(.*) http://www.domain.com/$1/vintage/$2
RedirectMatch 301 /(.*)/collection/(.*) http://www.domain.com/$1/$2

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB